Roles & Permissions Overview
The GB App uses Spatie Laravel Permission for role-based access control (RBAC). Roles can have multiple permissions, and users can have multiple roles.List Roles
Retrieve all roles with their associated permissions.Authentication & Permissions
Valid session or Sanctum token
super-adminrolerole.indexpermissionrole.createpermissionrole.updatepermissionrole.destroypermission
Response
Returns Inertia view with:Array of roles with permissions relationship
All available permissions in the system
Role Object Structure
Role ID
Role name
Guard name (typically “sanctum”)
Array of permission objects assigned to this role
Creation timestamp
Last update timestamp
Permission Object Structure
Permission ID
Permission name (e.g., “user.create”, “report.edit”)
Guard name
Example Request
Example Response
Create Role
Create a new role with assigned permissions.Request Body
Unique role name
Array of permission names to assign
Example Request
Response
Returns array of all roles with permissions (200 status).Update Role
Update an existing role and its permissions.Path Parameters
Role ID to update
Request Body
Updated role name
Updated array of permission names
Example Request
Response
Returns array of all roles with updates applied (200 status).Delete Role
Delete a role from the system.Path Parameters
Role ID to delete
Example Request
Response
Returns array of remaining roles (200 status).Common Permissions
Here are some common permissions in the GB App:User Management
user.index- View users listuser.create- Create new usersuser.update- Update usersuser.destroy- Delete usersuser.show- View user details
Role Management
role.index- View roles listrole.create- Create new rolesrole.update- Update rolesrole.destroy- Delete roles
Report Management
report.create- Create/edit reportsreport.edit- Edit reportsreport.destroy- Delete reportsreport.view- View reportsimport-report- Import reports from Power BI
Report Filters
report.filter.index- View filtersreport.filter.create- Create filtersreport.filter.update- Update filtersreport.filter.destroy- Delete filters
Business Modules
ver-lista-precios- View price listsrutas-tecnicas.ver- View technical routesrutas-tecnicas.crear- Create technical routesrutas-tecnicas.editar- Edit technical routesrutas-tecnicas.eliminar- Delete technical routesrutas-tecnicas.ver-todos- View all technical routes (supervisor)
Special Permissions
update-reports- Update user report assignmentsupdate-filters- Update user filter assignmentsset-default- Set default report view
Super Admin Role
Thesuper-admin role bypasses all permission checks. Users with this role have unrestricted access to all features.
Permission Middleware
Routes use therole_or_permission middleware:
- The
super-adminrole, OR - Any of the listed permissions
Error Responses
500 Internal Server Error
403 Forbidden
Implementation Notes
Source:app/Http/Controllers/RoleController.php
Database Transactions
All role operations use database transactions to ensure data integrity:Permission Sync
Permissions are synced using Spatie’ssyncPermissions() method, which replaces all existing permissions with the new set.