When building JoRooms—a multi-tenant hotel booking ecosystem—we faced a challenge: How do we manage access for Super Admins, Hotel Managers, and Agents without creating a "spaghetti" of if/else statements?
The answer: Dynamic Role-Based Access Control (RBAC) using Spatie Laravel Permission.
🛠 The Architecture
We didn’t just want "Fixed Roles." We built a Flexible Role Engine where permissions are granular, and roles are simply "containers" for those permissions.
The Tech Stack:
Backend: Laravel & Spatie (The Source of Truth)
Logic: Laravel Policies (For multi-tenant hotel_id scoping)
Frontend: React (Conditional Rendering based on the User's Permission Snapshot)
🔑 Key Implementation Highlights
The Permissions Matrix
Instead of checking if($user->isManager()), we check if($user->can('manage-rooms')). This decouples the identity from the action.
Multi-Tenant Scoping (The "Hotel Boundary")
A manager at Hotel A should never edit rooms at Hotel B.…