Skip to content

jjanampa/laravel-admin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

laravel-admin

Laravel Admin is a drop-in admin panel package for Laravel which promotes rapid scaffolding & development, uses Material Dashboard

Requirements

Laravel >=7
PHP >= 7.0

Features:

  1. Admin User, Role & Permission Manager:
  2. Activity Log:
  3. Page CRUD:
  4. Settings:
  5. Login, Forgot Password
  6. Profile

Packages used:

Assets used:


Installation

After initializing instance of Laravel

  1. Autoloading: By default, module classes are not loaded automatically. You can autoload your modules using psr-4, add "Modules\\": "Modules/" in composer.json.

    {
      "autoload": {
        "psr-4": {
          "App\\": "app/",
          "Modules\\": "Modules/",
        }
      }
    }

    Tip: don't forget to run composer dump-autoload afterwards.

  2. Run

    composer require jjanampa/laravel-admin
    
  3. Install the admin package.

    php artisan laravel-admin:install
    

    Service provider will be discovered automatically.

    execute php artisan laravel-admin:install --force to force the installation, this process recreate the Admin module, removes and recreates the following tables: admin_users, admin_roles, admin_permissions, admin_permission_role, admin_role_user, pages, settings

Logging In

Visit (APP_URL)/admin to access the admin panel.

The default admin login is:

Email Address: [email protected]
Password: secret

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:

    // Check role anywhere
    if (auth('admin')->user()->hasRole('editor')) {
        // Do admin stuff here
    } else {
        // Do nothing
    }
    
    // Check role in route middleware
    Route::resource('pages', 'Dashboard\PagesController')->middleware('role:editor');
  6. For checking permissions see below:

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

Learn more about ACL from here

For activity log please read spatie/laravel-activitylog docs

Screenshots

Admin Users Admin Roles Admin Permissions
Admin Users Admin Roles Admin Permissions
Pages Activity Log Settings
Pages Activity Log Settings
Profile Login Forgot Password
Profile Login Forgot Password