Overview
Admin components provide interfaces for system administrators to manage application settings and users. These components are restricted to users with theadmin role.
SystemSettings
Location:app/Livewire/Admin/SystemSettings.php:8
View: resources/views/livewire/admin/system-settings.blade.php
Purpose
Manages global system configuration including contact information and location data for the NutriFit application.Properties
| Property | Type | Default | Description |
|---|---|---|---|
telefono | string | '' | Contact phone number |
email_contacto | string | '' | Contact email address |
direccion | string | '' | Physical address |
latitud | ?float | null | Geographic latitude |
longitud | ?float | null | Geographic longitude |
Validation Rules
Methods
mount(): void
Location: app/Livewire/Admin/SystemSettings.php:35
Initializes the component with existing system settings from the database.
save(): void
Location: app/Livewire/Admin/SystemSettings.php:48
Validates and persists system settings to the database.
Process:
- Validates all input fields
- Updates settings using
SystemSetting::updateSettings() - Displays success message
success: “Configuración actualizada correctamente.”
Usage Example
UsersTable
Location:app/Livewire/Admin/UsersTable.php:11
View: resources/views/livewire/admin/users-table.blade.php
Purpose
Provides a paginated, filterable table for managing users in the system with search, role filtering, and state filtering capabilities.Traits
WithPagination- Enables pagination support
Properties
| Property | Type | Default | Description |
|---|---|---|---|
search | string | '' | Search term for name/email |
role_id | string | '' | Filter by user role |
user_state_id | string | '' | Filter by user state |
userToToggle | ?int | null | User ID for deactivation modal |
userToActivate | ?int | null | User ID for activation modal |
Query String Parameters
Location:app/Livewire/Admin/UsersTable.php:21
The component persists filter state in the URL:
Event Listeners
Methods
openDeactivateModal(int $userId): void
Location: app/Livewire/Admin/UsersTable.php:30
Opens the deactivation confirmation modal for a specific user.
openActivateModal(int $userId): void
Location: app/Livewire/Admin/UsersTable.php:36
Opens the activation confirmation modal for a specific user.
closeModal(): void
Location: app/Livewire/Admin/UsersTable.php:42
Closes any open modal dialogs.
updatingSearch(): void
Location: app/Livewire/Admin/UsersTable.php:48
Resets pagination when search term changes.
updatedRoleId(): void
Location: app/Livewire/Admin/UsersTable.php:53
Resets pagination when role filter changes.
updatedUserStateId(): void
Location: app/Livewire/Admin/UsersTable.php:58
Resets pagination when state filter changes.
clearFilters(): void
Location: app/Livewire/Admin/UsersTable.php:63
Resets all filters and pagination to their default state.
render()
Location: app/Livewire/Admin/UsersTable.php:69
Builds and executes the query to fetch filtered, paginated users.
Query Logic:
- Excludes the authenticated user
- Eager loads
roleanduserStaterelationships - Filters by role if specified
- Filters by user state if specified
- Searches name and email if search term provided
- Orders by creation date (latest first)
- Paginates with 15 users per page
users- Paginated collection of usersroles- All available rolesstates- All available user states
Usage Example
Search Implementation
Location:app/Livewire/Admin/UsersTable.php:82
Searches across both name and email fields:
Security Considerations
- Both components are protected by middleware ensuring only admins can access them
- User table excludes the currently authenticated user from management
- All inputs are validated server-side
- Email validation ensures proper format
- Coordinate validation ensures valid geographic ranges
Related Models
App\Models\SystemSetting- Stores system configurationApp\Models\User- User accountsApp\Models\Role- User rolesApp\Models\UserState- User account states