shadowbane/authorization-module

0.3.1 2020-12-07 02:21 UTC

This package is auto-updated.

Last update: 2024-11-07 11:19:07 UTC


README

Modular Authorization package for Laravel Backpack

Yet another Admin interface for spatie/laravel-permission. It allows admins to easily add/edit/remove users, roles and permissions, using Laravel Backpack. This module is based on Backpack\PermissionManager and spatie/laravel-permission. So if you like the package, please support the original authors.

Installation

  1. Make sure you've already installed Backpack.

  2. Install nWidart/laravel-modules and joshbrw/laravel-module-installer

  3. In your terminal:

    composer require backpack/permissionmanager
  4. Finish all installation steps for spatie/laravel-permission, which as been pulled as a dependency. Run its migrations. Publish its config files. Most likely it's:

    php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"
    php artisan migrate
    php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="config"
    // then First, add the Spatie\Permission\Traits\HasRoles trait to your User model(s)
  5. Publish the config file & run the migrations

    php artisan vendor:publish --provider="Modules\Authorization\Providers\AuthorizationServiceProvider" --tag="config"
  6. Add CrudTrait and HasRole to user model

    <?php namespace App\Models;
    
    use Backpack\CRUD\app\Models\Traits\CrudTrait; // <------------------------------- this one
    use Spatie\Permission\Traits\HasRoles;// <---------------------- and this one
    use Illuminate\Foundation\Auth\User as Authenticatable; 
    
    class User extends Authenticatable
    {
        use CrudTrait; // <----- this
        use HasRoles; // <------ and this
    
        /**
         * Your User Model content
         */
  7. [Optional] Add a menu item for it in resources/views/vendor/backpack/base/inc/sidebar_content.blade.php or menu.blade.php:

    <!-- Users, Roles, Permissions -->
    <li class="nav-item nav-dropdown">
        <a class="nav-link nav-dropdown-toggle" href="#">
            <i class="nav-icon la la-users"></i> Authentication
        </a>
    
        <ul class="nav-dropdown-items">
            <li class="nav-item">
                <a class="nav-link" href="{{ backpack_url('role') }}">
                    <i class="nav-icon la la-id-badge"></i><span>Roles</span>
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="{{ backpack_url('permission') }}">
                    <i class="nav-icon la la-key"></i><span>Permissions</span>
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="{{ backpack_url('user') }}">
                    <i class="nav-icon la la-user"></i>
                    <span>Users</span>
                </a>
            </li>
        </ul>
    </li>

Change log

Documentation

Coming soon

License

Credits

All original developers of