Documentation Index
Fetch the complete documentation index at: https://mintlify.com/alber1802/AvaluoVehicular/llms.txt
Use this file to discover all available pages before exploring further.
The user management module gives administrators full control over every account in Avalúo Vehicular. Only users who carry the admin role can access /usuarios — any authenticated user without it is immediately redirected with an error. From this panel, admins can create new evaluator accounts, update profile data, rotate passwords, promote or demote roles, temporarily suspend access, and delete accounts that are no longer needed.
User Model
User accounts are stored in the users table and backed by the App\Models\User model. The model uses Laravel Fortify’s TwoFactorAuthenticatable trait and Spatie’s HasRoles trait alongside the standard Authenticatable base class.
| Field | Type | Description |
|---|
name | string | Full display name of the user |
email | string | Unique email address used for login |
password | string (hashed) | Bcrypt-hashed password, hidden from serialization |
phone | string|null | Optional contact phone number |
is_active | boolean | Whether the account has been activated |
is_suspended | boolean | true blocks the user from logging in |
email_verified_at | datetime|null | Timestamp of email verification |
two_factor_secret | string|null | TOTP secret for 2FA (hidden from serialization) |
two_factor_recovery_codes | string|null | Encrypted recovery codes (hidden from serialization) |
two_factor_confirmed_at | datetime|null | When the user confirmed their 2FA device |
remember_token | string|null | Session persistence token (hidden from serialization) |
Routes
All routes are grouped under the /usuarios prefix and require the auth and verified middleware.
List Users
Returns all users with their assigned roles, plus a map of available role IDs to names. Renders the User/ListUsers Inertia page. Access is restricted to users with the admin role — anyone else is bounced back with an error flash.
Create a User
Creates a new account and immediately assigns a role via Spatie’s syncRoles. The role must already exist in the roles table; if it does not, the request fails with an error. New accounts are created with is_active = 0 until the user activates them.
Required fields:
| Field | Rule |
|---|
name | required, string |
email | required, valid email, unique |
password | required, string, min: 8 |
role | required, must exist in roles.name |
phone | optional, string |
Update User Data
POST /usuarios/actualizar/{id}
Updates name, email, and phone. Optionally re-assigns a role if a role field is included in the request.
Change Password
POST /usuarios/cambiar-password/{id}
Replaces a user’s password with a new bcrypt hash. The new password must be at least 8 characters.
$user->update([
'password' => Hash::make($request->password),
]);
Assign a Role
POST /usuarios/cambiar-rol/{id}
Calls syncRoles to replace the user’s current roles with the one supplied. An admin cannot change their own role through this endpoint — the system returns an error if Auth::user()->id === $user->id.
Role assignment requires the target role to already exist. Visit /roles/listado to create roles before assigning them to users.
Suspend / Unsuspend a User
POST /usuarios/suspend/{id}
Toggles the is_suspended flag. Send is_suspended: true to block the user from logging in, or is_suspended: false to restore their access. An admin cannot suspend themselves through this endpoint.
$user->update([
'is_suspended' => $request->is_suspended, // true or false
]);
Delete a User
DELETE /usuarios/eliminar/{id}
Permanently removes the user record. The system prevents deletion of any user who holds the admin role — attempting to do so returns an error without modifying the database.
Deleting a user does not cascade to their vehicle or appraisal records. Any Vehiculo and Avaluo rows that reference the deleted user’s ID remain in the database with their id_evaluador intact. Assign or migrate those records before removing the account if record ownership matters for your workflow.
Available Roles
Avalúo Vehicular ships with two application-level roles managed through Spatie Laravel Permission:
| Role | Description |
|---|
admin | Full access to all modules including user management, roles, depreciation configuration, and recycle bin. Cannot be deleted. |
evaluator | Can create and manage their own vehicle registrations and appraisals. Cannot access the admin panel or user list. |
Roles are stored in the roles table created by the Spatie permission migration and are associated with users through the model_has_roles pivot table.
Operations Reference
| Operation | Route | Required Role |
|---|
| View user list | GET /usuarios/listado | admin |
| Create user | POST /usuarios/crear | admin |
| Update user data | POST /usuarios/actualizar/{id} | admin |
| Change password | POST /usuarios/cambiar-password/{id} | admin |
| Assign role | POST /usuarios/cambiar-rol/{id} | admin |
| Suspend / unsuspend | POST /usuarios/suspend/{id} | admin |
| Delete user | DELETE /usuarios/eliminar/{id} | admin |