SaborGestion uses a singleDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Henry4ndrew/saborGestion/llms.txt
Use this file to discover all available pages before exploring further.
role column on the users table to control which parts of the application each person can reach. There are four roles. Every route group in web.php declares which roles are allowed via the role middleware alias.
The four roles
| Role | Description |
|---|---|
admin | Full access to every section of the application, including user management |
mesero | Access to table management (mesas) and the mesero dashboard |
cocinero | Access to product catalog (productos), ingredient inventory (inventario), and the cocinero dashboard |
cajero | Access to orders, comandas, delivery, invoices, payments, and cash-register closing |
role column is an ENUM with a default value of mesero:
How RoleMiddleware works
App\Http\Middleware\RoleMiddleware is the single piece of code that enforces role-based access. It runs on every request where the role:… middleware alias appears on a route.
role:admin,cocinero becomes $roles = ['admin', 'cocinero']). It:
- Redirects to
/loginif no authenticated session exists. - Reads
Auth::user()->rolefrom the database. - Calls
in_arrayto check whether the user’s role is in the allowed list. - Passes the request through if matched, or aborts with HTTP 403 if not.
The allowed roles list is declared explicitly on each route. The middleware itself does not contain any hardcoded bypass logic — it simply checks whether the user’s role appears in whatever list the route provides.
Admin bypass in DashboardController
TheDashboardController uses a private helper authorizeRole that adds an admin bypass on top of the middleware check. This lets administrators view any role-specific dashboard without being enrolled in that role:
$this->authorizeRole('mesero') allows both users whose role is mesero and users whose role is admin to reach that dashboard. The four role-specific dashboard methods each call this helper with their own role string.
Route permission map
Every resource route group inweb.php declares its allowed roles inline. The table below lists all protected route groups and the roles that can access them.
| Route resource | Middleware | Allowed roles |
|---|---|---|
productos | role:admin,cocinero | admin, cocinero |
inventario | role:admin,cocinero | admin, cocinero |
mesas | role:admin,mesero | admin, mesero |
pedidos | role:admin,cajero | admin, cajero |
comandas | role:admin,cajero | admin, cajero |
delivery | role:admin,cajero | admin, cajero |
facturas | role:admin,cajero | admin, cajero |
pagos | role:admin,cajero | admin, cajero |
cierres | role:admin,cajero | admin, cajero |
usuarios | role:admin | admin only |
routes/web.php:
Role access matrix
The table below shows at a glance which roles can access each section.| Section | admin | mesero | cocinero | cajero |
|---|---|---|---|---|
| Dashboard (own role) | ✓ | ✓ | ✓ | ✓ |
| All dashboards | ✓ | — | — | — |
| productos | ✓ | — | ✓ | — |
| inventario | ✓ | — | ✓ | — |
| mesas | ✓ | ✓ | — | — |
| pedidos | ✓ | — | — | ✓ |
| comandas | ✓ | — | — | ✓ |
| delivery | ✓ | — | — | ✓ |
| facturas | ✓ | — | — | ✓ |
| pagos | ✓ | — | — | ✓ |
| cierres | ✓ | — | — | ✓ |
| usuarios | ✓ | — | — | — |
403 behavior
When a user requests a route they are not authorized for, the middleware calls:resources/views/errors/403.blade.php.
Changing a user’s role
Via the admin UI
Click the edit icon
Find the user in the table and click the edit icon. This opens
/usuarios/{usuario}/edit.Select the new role
Choose the desired role from the Rol dropdown:
admin, mesero, cocinero, or cajero.Via Tinker
User management
Full CRUD reference for the /usuarios interface, including validation rules and Tinker examples
Middleware reference
Detailed walkthrough of how RoleMiddleware is registered and applied