AdminController
extends BaseController
in package
Admin Controller
This controller manages all admin-related operations including user management, role-based access control, module mapping, and administrative functions. It provides comprehensive user administration capabilities with security features like 2FA, activity logging, and permission management.
Table of Contents
Methods
- __construct() : void
- Create a new AdminController instance.
- addMapping() : View
- Show form for adding new role-module mapping.
- addRollModuleAccess() : RedirectResponse
- Add new role-module access mapping.
- changePassword() : RedirectResponse
- Change user password with validation.
- checkEmailExists() : void
- Check if email already exists in the system.
- create() : View
- Show the form for creating a new admin user.
- deleteMapping() : void
- Delete role-module mapping.
- destroy() : RedirectResponse
- Remove the specified admin user from storage.
- edit() : View
- Show the form for editing the specified admin user.
- index() : View|JsonResponse
- Display a listing of admin users with DataTables support.
- mapping() : View
- Display role-module mapping interface.
- matchOldPassword() : User|false
- Match old password for verification.
- profilePage() : View
- Load and display user profile page.
- show() : void
- Display the specified admin user details.
- store() : RedirectResponse
- Store a newly created admin user in storage.
- update() : RedirectResponse
- Update the specified admin user in storage.
- updateProfile() : RedirectResponse
- Update user profile information.
Methods
__construct()
Create a new AdminController instance.
public
__construct() : void
Checks if user is logged in and has proper permissions. Redirects to appropriate page if permissions are not met.
addMapping()
Show form for adding new role-module mapping.
public
addMapping(Request $request) : View
Displays form with available roles and modules for creating new role-based access control mappings.
Parameters
- $request : Request
Return values
ViewaddRollModuleAccess()
Add new role-module access mapping.
public
addRollModuleAccess(Request $request) : RedirectResponse
Creates new role-module access relationship with specified access type. Defaults to 'C' (Create) access type if not specified.
Parameters
- $request : Request
Return values
RedirectResponsechangePassword()
Change user password with validation.
public
changePassword(Request $request[, string $active = "changepass" ]) : RedirectResponse
Validates old password, updates to new password, and generates new session token. Includes comprehensive logging for security audit.
Parameters
- $request : Request
- $active : string = "changepass"
Return values
RedirectResponsecheckEmailExists()
Check if email already exists in the system.
public
checkEmailExists(Request $request) : void
Validates email uniqueness for user creation and updates. Returns JSON response for AJAX validation.
Parameters
- $request : Request
create()
Show the form for creating a new admin user.
public
create(Request $request) : View
Displays the user creation form with available roles for assignment.
Parameters
- $request : Request
Return values
ViewdeleteMapping()
Delete role-module mapping.
public
deleteMapping(Request $request) : void
Removes specific role-module access relationship. Returns JSON response for AJAX operations.
Parameters
- $request : Request
destroy()
Remove the specified admin user from storage.
public
destroy(int $id) : RedirectResponse
Deletes user account and associated files (images, thumbnails). Logs the deletion activity for audit purposes.
Parameters
- $id : int
Return values
RedirectResponseedit()
Show the form for editing the specified admin user.
public
edit(Request $request, int $id) : View
Displays the user edit form with security key validation. Requires valid security key to prevent unauthorized access.
Parameters
- $request : Request
- $id : int
Return values
Viewindex()
Display a listing of admin users with DataTables support.
public
index(Request $request) : View|JsonResponse
Provides a paginated list of admin users with filtering capabilities. Supports AJAX requests for DataTables with search and filter functionality. Excludes developer role from the listing.
Parameters
- $request : Request
Return values
View|JsonResponsemapping()
Display role-module mapping interface.
public
mapping(Request $request) : View
Shows the mapping between roles and modules with access types. Provides comprehensive view of role-based access control configuration.
Parameters
- $request : Request
Return values
ViewmatchOldPassword()
Match old password for verification.
public
matchOldPassword(Request $request, int $adminId, string $oldPassword) : User|false
Validates the provided old password against the stored hash. Used for password change verification.
Parameters
- $request : Request
- $adminId : int
- $oldPassword : string
Return values
User|falseprofilePage()
Load and display user profile page.
public
profilePage(Request $request[, string $active = "details" ]) : View
Shows user profile with different active tabs for details, password change, and other profile management options.
Parameters
- $request : Request
- $active : string = "details"
Return values
Viewshow()
Display the specified admin user details.
public
show(int $id, Request $request) : void
Shows detailed user information in a formatted HTML table. Displays user profile information including personal details and status.
Parameters
- $id : int
- $request : Request
store()
Store a newly created admin user in storage.
public
store(Request $request) : RedirectResponse
Validates user input, creates new user with hashed password, and logs the activity. Supports 2FA configuration.
Parameters
- $request : Request
Return values
RedirectResponseupdate()
Update the specified admin user in storage.
public
update(Request $request, int $id) : RedirectResponse
Handles user profile updates including image upload, 2FA configuration, and password changes. Supports image processing and thumbnail generation.
Parameters
- $request : Request
- $id : int
Return values
RedirectResponseupdateProfile()
Update user profile information.
public
updateProfile(Request $request) : RedirectResponse
Handles profile updates including email and name changes. Logs profile update activities for audit purposes.
Parameters
- $request : Request