The Admin Management module is a pre-built and maintained module for starting a new web application in Laravel. This module is designed to save time and effort in implementing common admin management features in Laravel projects, while promoting consistency and standardization in module design and implementation.
The module includes the following features:
- Auth Management: Login,logout,register,forgot password, change password user in your system.
- User Management: Create, read, update and delete users in the system.
- Role Management: Create, read, update and delete roles for users in the system.
- Permission Management: Create, read, update and delete permissions for roles in the system.
- Laravel 8.x or higher
- PHP 7.4 or higher
- AdminLTE theme
- Spatie Laravel Permission
- Nwidart Laravel Module
- Install Laravel on your system.
- Install Spatie Laravel Permission and set it up according to the documentation.
- Install Nwidart laravel and setup according to the documentation.
- Clone the Admin Management module repository into your Laravel project's Modules directory:
cd /path/to/your/laravel/project/Modules
git clone https://github.com/example/AdminManagement.git
Run the module enable:
php artisan module:enable AdminManagement
php artisan vendor:publish --tag=public --provider="Modules\AdminManagement\Providers\AdminManagementServiceProvider"
php artisan module:seed AdminManagement
Once the module is installed and set up, you can access the admin management features by navigating to the appropriate URLs:
- Auth Management: /adminmanagement/login
- User Management: /users
- Role Management: /roles
- Permission Management: /permissions
You can use master.blade.php, and app.blade.php
@extends('adminmanagement::layouts.app')
@section('content')
<x-adminmanagement::page-header pageTitle="Creare User" :breadcrumbs="['Home', 'Creare User']" />
@endsection
@push('script')
@endpush
@push('style')
@endpush
Now we require to install Spatie package for ACL, that way we can use its method. Also we will install form collection package. So Open your terminal and run bellow command.
composer require spatie/laravel-permission
composer require laravelcollective/html
Now open config/app.php file and add service provider and aliase.
config/app.php
'providers' => [
....
Spatie\Permission\PermissionServiceProvider::class,
],
We can also custom changes on Spatie package, so if you also want to changes then you can fire bellow command and get config file in config/permission.php and migration files.
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
Now you can see permission.php file and one migrations. so you can run migration using following command:
php artisan migrate
add middleware in Kernel.php file this way :
app/Http/Kernel.php
protected $middlewareAliases = [
....
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
]
add HasRoles traits
app/Http/Models/user.php
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, HasRoles;
php artisan test Modules/AdminManagement