Looking to hire Laravel developers? Try LaraJobs

laravel-admin maintained by acmepackage

Description
Laravel Admin Panel
Author
Last update
2024/06/26 13:10 (dev-main)
License
Links
Downloads
76

Comments
comments powered by Disqus

Laravel Admin Panel

An admin panel for managing users, roles, permissions & crud.

Requirements

Laravel >=9
PHP >= 8.0
composer `2.4.2`
node `16.17.1`
npm `8.15.0`
WebPack and laravel mix
Now we Support Laravel 9

templates version

Bootstrap v4

AdminLTE 3.1

Features

  • User, Role & Permission Manager
  • CRUD Generator
  • Activity Log
  • Page CRUD
  • Settings

Installation

  1. Run
    composer require acmepackage/laravel-admin
    
  2. Make sure your user model's has a HasRoles trait app/Models/User.php.
    class User extends Authenticatable
    {
        use Notifiable, HasRoles;
    
        ...
    
  3. Create auth assets
    php artisan ui bootstrap --auth  
    
    and don't replace auth views
  4. Add the following line to the "web.php" file located in routes folder
    require('admin.php');
  1. Register localization middleware in app/Http/Kernel.php
protected $middlewareGroups = [
'web' => [

            \App\Http\Middleware\Localization::class,

        ],

    ];
  1. Run the following command
php artisan vendor:publish --all
  1. Remove your package.json located in the project root dir and rename package.json.example in the same dir to package.json then rename webpack.mix.js.example to webpack.mix.js

  2. Run the following commands to install node and build the node packages

    npm install
    npm install --save-dev webpack
    npm run dev
  1. To create seeder for roles and language, add the following lines to DatabaseSeeder.php in the "run" function
     $this->call([
             RoleTableSeeder::class,
            LanguageTableSeeder::class,
        ]);
  1. Finally run
   php artisan migrate --seed
  1. Open the following url after running "php artisan serve" your_url/admin

Note: we use webpack only not vite

Note: If you are using Laravel 7+ then scaffold the authentication with bootstrap for a better experience. . You can generate CRUD easily through generator tool now.

Usage

  1. Create some permissions.

  2. Create some roles.

  3. Assign permission(s) to role.

  4. Create user(s) with role.

  5. For checking authenticated user's role see below:

    // Add role middleware in app/Http/Kernel.php
    protected $routeMiddleware = [
        ...
        'role' => \App\Http\Middleware\CheckRole::class,
    ];
    
    // Check role anywhere
    if (Auth::check() && Auth::user()->hasRole('admin')) {
        // Do admin stuff here
    } else {
        // Do nothing
    }
    
    // Check role in route middleware
    Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth', 'role:admin']], function () {
       Route::get('/', ['uses' => 'AdminController@index']);
    });
    
    // Check permission in route middleware
    Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth', 'can:write_user']], function () {
       Route::get('/', ['uses' => 'AdminController@index']);
    });
    
  6. For checking permissions see below:

    if ($user->can('permission-name')) {
        // Do something
    }
    

Learn more about ACL from here

For activity log please read spatie/laravel-activitylog docs

Screenshots

users

activity log

generator

settings

Author

[Mohamed Hassan] :email: Email Me

##reference

Sohel Amin :email: Email Me

License

This project is licensed under the MIT License - see the License File for details