我正在尝试以超级管理员身份访问仪表板我使用 laratrust 设置角色和权限:laratrustSeeder.php 文件:
<?php
return [
'role_structure' => [
'super_admin' => [
'users' => 'c,r,u,d',
'categories' => 'c,r,u,d'
],
数据库种子.php:
public function run()
{
// $this->call(UsersTableSeeder::class);
$this->call([
LaratrustSeeder::class,
UsersTableSeeder::class,
]);
我的 UsersTableSeeder.php
public function run()
{
//
$user = App\User::create([
'name'=>'super_admin',
'email'=>'super_admin@app.com',
'password'=>bcrypt('123456'),
]);
$user->attachRole('super_admin');
} //end of run
这是我的路线:
Route::prefix('dashboard')
->name('dashboard.')
->middleware(['auth','role:super_admin|admin'])
->group(function(){
//make route dashboard.welcome
Route::get('/', 'WelcomeController@index')->name('welcome');
//make route categories:
Route::resource('categories','CategoryController')->except(['show']);
Route::resource('roles','RoleController')->except(['show']);
});
现在我使用 super_admin 成功登录但无法浏览仪表板,我收到 403 错误:用户没有任何必要的访问权限。