Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Ary-dev04/DentControl/llms.txt
Use this file to discover all available pages before exploring further.
User Management
DentControl’s user management system allows you to create and manage users with different roles across multiple dental clinics. Users are associated with specific clinics and have role-based permissions.User Model Overview
TheUsuario model (app/Models/Usuario.php) extends Laravel’s authentication system with custom fields for dental clinic management.
User Structure
Key Fields
User Roles
DentControl supports three user roles:| Role | Description | Permissions |
|---|---|---|
| superadmin | System administrator | Full access to all clinics and system settings |
| dentista | Dentist/Doctor | Manage patients, appointments, treatments in their clinic |
| asistente | Assistant | Limited access to support dentists |
Roles are defined as enum values in the database:
superadmin, dentista, asistente.Creating Users
Users can be created through the admin interface or programmatically.Through Admin Interface
TheUsuarioController (app/Http/Controllers/Admin/UsuarioController.php) handles user creation.
Fill user details
Provide the required information:
- Clínica: Select the clinic to associate the user with
- Nombre: First name (min 3 letters, only letters and spaces)
- Apellido Paterno: Paternal surname (required)
- Apellido Materno: Maternal surname (optional)
- Usuario: Username (4-20 alphanumeric characters, unique)
- Contraseña: Password (see requirements below)
- Rol: Select role (dentista or asistente)
- Cédula Profesional: Professional license (required for dentists, 7-10 digits)
Password Requirements
DentControl enforces strong password policies:Programmatic User Creation
You can create users programmatically using theUsuario model:
The
Usuario model uses the 'password' => 'hashed' cast, which automatically hashes passwords using bcrypt when saving.Assigning Roles
Roles are assigned during user creation and can be updated later.Role Assignment Rules
-
Dentista role:
- Requires
cedula_profesional(professional license) - Can manage patients and treatments
- Creates appointments and clinical notes
- Requires
-
Asistente role:
- No professional license required
- Supports dentists with administrative tasks
- Limited clinical access
-
Superadmin role:
- Cannot be changed or suspended through the interface
- Protected from accidental modifications
- Full system access
Associating Users with Clinics
Every user must be associated with a clinic through theid_clinica foreign key.
Clinic Relationship
Usuario Model Relationship
Accessing User’s Clinic
User Status Management
Users can be activated or deactivated without deleting their records.Status Values
- activo: User can log in and access the system
- baja: User is suspended and cannot log in
Toggle User Status
ThetoggleStatus method (app/Http/Controllers/Admin/UsuarioController.php:91) handles status changes:
Updating Users
Users can be edited to update their information.Editable Fields
- Personal information (name, surnames)
- Username (must remain unique)
- Password (optional - only if changing)
- Role (except for superadmin)
- Professional license
- Associated clinic
Update Process
User Relationships
TheUsuario model has several important relationships:
Clinic Relationship
Appointments (Citas)
Clinical Notes
Using Relationships
Authentication
TheUsuario model extends Authenticatable for Laravel’s authentication system.
Custom Authentication Methods
Usuario Model
Login Example
Troubleshooting
Cannot create user - validation errors
Cannot create user - validation errors
Common validation issues:
- Username already exists: Each username must be unique
- Password too weak: Must meet all requirements (8+ chars, mixed case, numbers)
- Name contains invalid characters: Only letters and spaces allowed
- Missing professional license: Required for dentista role
storage/logs/laravel.log for detailed validation errors.User cannot log in
User cannot log in
Verify:
-
User status is active:
-
Password is correct: Test password hash:
-
User exists in database:
Password not hashing automatically
Password not hashing automatically
Ensure the This cast automatically hashes passwords when saving.
Usuario model has the password cast:Cannot edit or suspend superadmin
Cannot edit or suspend superadmin
This is intentional! The system protects superadmin users from accidental changes.To modify a superadmin:
- Access the database directly
- Or remove the protection check in the controller (not recommended)
User associated with wrong clinic
User associated with wrong clinic
Update the clinic association:Or through the admin interface by editing the user.
Best Practices
- Always use strong passwords: Enforce the built-in password requirements
- Regularly audit user access: Review active users and their roles
- Use status toggle instead of deletion: Preserve user history by deactivating
- Associate users correctly: Ensure users belong to the right clinic
- Protect superadmin accounts: Never expose superadmin credentials
- Log user actions: Track important user activities for security
Next Steps
Configuration
Configure your application environment
Database Setup
Learn about database structure and migrations