1. Go to this page and download the library: Download shiwuhao/laravel-rbac library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shiwuhao / laravel-rbac example snippets
namespace App\Models;
class Role extends \Shiwuhao\Rbac\Models\Role
{
}
namespace App\Models;
class Permission extends \Shiwuhao\Rbac\Models\Permission
{
}
namespace App\Models;
class Action extends \Shiwuhao\Rbac\Models\Action
{
}
namespace App\Models;
use Shiwuhao\Rbac\Models\Traits\UserTrait;
class User extends Authenticatable
{
use UserTrait; // 添加这个trait到你的User模型中
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Shiwuhao\Rbac\Models\Traits\PermissibleTrait;
class Menu extends Model
{
use PermissibleTrait;
}