Skip to main content

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.
FieldTypeDescription
namestringFull display name of the user
emailstringUnique email address used for login
passwordstring (hashed)Bcrypt-hashed password, hidden from serialization
phonestring|nullOptional contact phone number
is_activebooleanWhether the account has been activated
is_suspendedbooleantrue blocks the user from logging in
email_verified_atdatetime|nullTimestamp of email verification
two_factor_secretstring|nullTOTP secret for 2FA (hidden from serialization)
two_factor_recovery_codesstring|nullEncrypted recovery codes (hidden from serialization)
two_factor_confirmed_atdatetime|nullWhen the user confirmed their 2FA device
remember_tokenstring|nullSession persistence token (hidden from serialization)

Routes

All routes are grouped under the /usuarios prefix and require the auth and verified middleware.

List Users

GET /usuarios/listado
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

POST /usuarios/crear
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:
FieldRule
namerequired, string
emailrequired, valid email, unique
passwordrequired, string, min: 8
rolerequired, must exist in roles.name
phoneoptional, 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:
RoleDescription
adminFull access to all modules including user management, roles, depreciation configuration, and recycle bin. Cannot be deleted.
evaluatorCan 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

OperationRouteRequired Role
View user listGET /usuarios/listadoadmin
Create userPOST /usuarios/crearadmin
Update user dataPOST /usuarios/actualizar/{id}admin
Change passwordPOST /usuarios/cambiar-password/{id}admin
Assign rolePOST /usuarios/cambiar-rol/{id}admin
Suspend / unsuspendPOST /usuarios/suspend/{id}admin
Delete userDELETE /usuarios/eliminar/{id}admin

Build docs developers (and LLMs) love