Overview
TheAdminController handles the superadmin dashboard view for the DentControl SaaS platform. It provides system-wide statistics including active clinics count, active users count, total patients, and displays the most recently registered clinics.
Location: app/Http/Controllers/Admin/AdminController.php
Namespace: App\Http\Controllers\Admin
Methods
index()
Displays the superadmin dashboard with aggregated statistics from the entire platform. Route:GET /admin/dashboard
Route Name: admin.dashboard
Middleware:
auth- User must be authenticatedcan:admin-only- User must have superadmin role
admin.dashboard Blade view with the following data:
Count of clinics with
estatus = 'activo'Count of users with
estatus = 'activo'Total count of all patients in the system
Collection of the 5 most recently created clinics (ordered by
created_at DESC)-
Active clinics count:
-
Active users count:
-
Total patients:
-
Recent clinics:
Access Control
Authorization:- Only users with
rol = 'superadmin'can access this controller - Protected by the
can:admin-onlymiddleware gate - Unauthorized access attempts are redirected
- Must be authenticated (
authmiddleware) - Must have
superadminrole - Account status must be
activo
Related Models
Dependencies:App\Models\Clinica- For clinic statistics and listingsApp\Models\Usuario- For user statisticsApp\Models\Paciente- For patient count
- Queries are direct counts and collections (no explicit relationships used in this controller)
Summary
TheAdminController provides 1 method for the superadmin dashboard:
- index() - Display system-wide statistics and recent clinic registrations
- Real-time statistics from database
- Active-only counts for clinics and users
- Recent clinic overview (last 5 registrations)
- Role-based access control (superadmin only)
- System health monitoring at a glance
- Active clinics count
- Active users count
- Total patients across all clinics
- Recent clinic registrations table