feat: platform admin backend — controllers, services, routes, tests
Add cross-organisation admin API endpoints behind role:super_admin middleware: - AdminOrganisationController: CRUD with search, filter, billing_status management - AdminUserController: user management with role assignment across orgs - AdminStatsController: platform-wide aggregate statistics - AdminActivityLogController: filterable activity log viewer - AdminImpersonationController + ImpersonationService: user impersonation with token-based session management and activity logging - BillingStatus enum, form requests, API resources, 23 feature tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Event;
|
||||
use App\Models\Organisation;
|
||||
use App\Models\Person;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
final class AdminStatsController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'data' => [
|
||||
'organisations' => [
|
||||
'total' => Organisation::withoutGlobalScopes()->count(),
|
||||
'by_billing_status' => Organisation::withoutGlobalScopes()
|
||||
->selectRaw('billing_status, COUNT(*) as count')
|
||||
->groupBy('billing_status')
|
||||
->pluck('count', 'billing_status'),
|
||||
],
|
||||
'events' => [
|
||||
'total' => Event::withoutGlobalScopes()->count(),
|
||||
'by_status' => Event::withoutGlobalScopes()
|
||||
->selectRaw('status, COUNT(*) as count')
|
||||
->groupBy('status')
|
||||
->pluck('count', 'status'),
|
||||
],
|
||||
'users' => [
|
||||
'total' => User::count(),
|
||||
'verified' => User::whereNotNull('email_verified_at')->count(),
|
||||
],
|
||||
'persons' => [
|
||||
'total' => Person::withoutGlobalScopes()->count(),
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user