Overview
The User Management module provides comprehensive user administration including user creation, role assignment, report access management, and special relationships for technical users and advisors. Controller:UserController (app/Http/Controllers/UserController.php:18)Model:
User (app/Models/User.php:20)Vue Components:
resources/js/Pages/Users/Index.vueresources/js/Pages/Users/Show.vue
Key Features
User CRUD
Create, read, update, and delete users with validation
Role Assignment
Assign multiple roles using Spatie Laravel Permission
Report Access
Control which Power BI reports users can access
Technical Relationships
Link advisors with technical users for collaborative workflows
LDAP Integration
Support for Active Directory authentication
Filter Management
Configure report filters per user
Data Model
TheUser model extends Laravel’s Authenticatable and includes multiple traits:
Fillable Attributes
Relationships
Reports (Many-to-Many):Permissions
User management routes require role-based permissions (routes/web.php:68-100):user.index: View user listuser.show: View user detailsuser.create: Create new usersuser.update: Edit existing usersuser.destroy: Delete usersupdate-reports: Manage user report assignmentsupdate-filters: Manage user report filtersset-default: Control dashboard report visibility
super-admin role bypass all permission checks.
API Endpoints
List Users
users: All users with reports and roles loadedroles: All available roles in the systemreports: All available Power BI reportstechnicalUsers: Users with role ‘tecnico’ or ‘técnico’
View User Details
user: Full user data with roles, permissions, reports, and technical usersroles: Available rolesreports: Available reportsfilters: Available report filterstechnicalUsers: Selectable technical users
Create User
- Create user with bcrypt password
- Sync assigned reports (many-to-many)
- Sync roles using Spatie Permission
- If role includes “Asesor”, sync technical users
- Only applies if user has “Asesor” role (case-insensitive)
- Validates that selected users have “tecnico” or “técnico” role
- Syncs valid technical user IDs to
advisor_technical_usertable
Update User
- Update user attributes
- Optionally update password if
change_passwordis true - Clear permissions and resync roles
- Handle technical users based on “Asesor” role
- Only syncs if payload includes
technical_usersfield - If user no longer has “Asesor” role, detaches all technical users
Delete User
Report Management
Update User Reports
- Uses Laravel’s
sync()method - Adds new report assignments
- Removes unspecified reports
Update Report Filters
- Syncs filters with pivot values including
user_id - Filters are applied when user views the report
Set Default Report
- Updates
showcolumn inuser_reportspivot table - If
show = true, report appears on dashboard - If
show = false, report is hidden from dashboard
Technical User Relationships
The system supports linking advisors with technical users for collaborative workflows (e.g., Technical Routes).Relationship Structure
Database Table:advisor_technical_user
Columns:
advisor_id: Foreign key to users (advisor)technical_user_id: Foreign key to users (technician)created_at: Timestampupdated_at: Timestamp
Use Cases
Scenario: Advisor A needs to create technical routes but doesn’t perform installations. They work with Technicians T1 and T2.Setup: Link Advisor A with T1 and T2 through
technicalUsers relationship.Result: When creating routes, Advisor A can only select T1 or T2. Routes are shared between advisor and assigned technician.Query Technical Users
The system queries technical users using role-based filtering:The query uses case-insensitive matching to handle both “tecnico” and “técnico” role names.
LDAP Integration
Users can authenticate via Active Directory (LDAP) or local credentials:LDAP User Attributes
guid: Unique identifier from LDAPdomain: LDAP domainis_ldap_user: Boolean flag
LDAP Check Method
Authentication Flow
- User enters username/email and password
- System checks
is_ldap_userflag - If LDAP user: Authenticate against Active Directory
- If local user: Authenticate against database
LDAP users do not have passwords stored in the database. The
password field should be null for LDAP accounts.User Types
Thetype field categorizes users:
employee: Internal staffcustomer: External customersdesigner: Design team memberstechnician: Technical service personnel- Other custom types as needed
Appended Attributes
The User model appends computed attributes to API responses:Role Names Accessor
Permission Names Accessor
User Interface
Index Page
Displays data table with columns:- ID
- Name
- Username
- Type
- Roles (badges)
- Report Count
- Actions (View, Edit, Delete)
User Detail Page
Tabs for:- User Info: Name, email, username, type, cedula, vendor code
- Roles & Permissions: Assigned roles with badge display
- Reports: Assigned reports with visibility toggles
- Report Filters: Configure filters per report
- Technical Users: Linked technical users (if Asesor role)
Validation & Security
Password Requirements
- Minimum length (configured in validation rules)
- Required only when
change_passwordis true on update - Stored using bcrypt hashing
Email Uniqueness
Emails must be unique across all users.Username Uniqueness
Usernames must be unique across all users.Role Validation
Role names are normalized to lowercase before comparison:Transaction Safety
All create and update operations use database transactions:Usage Workflow
Create User
Navigate to Users page and click “New User”. Fill in required fields: name, username, email, password.
Link Technical Users
If assigning “Asesor” role, select which technical users they collaborate with.
Related Modules
Roles
Manage roles and assign permissions
Reports
Configure Power BI reports
Report Filters
Define filters for report data
Technical Routes
Utilize advisor-technician relationships