我正在尝试限制对特定资源的访问HealthController
我正在使用 Spatie 和 Laravel。我已经设置了这样的路线。请注意,帖子路线工作正常,但健康路线并没有按照我的意愿行事。
路线:
Route::group( ['middleware' => ['auth']], function() {
Route::resource('users', 'UserController');
Route::resource('roles', 'RoleController');
Route::resource('posts', 'PostController');
Route::resource('health', 'HealthController');
});
模型:
<?php
namespace App;
use App\Search\Searchable;
use Illuminate\Database\Eloquent\Model;
class Health extends Model
{
use Searchable;
protected $guarded = [];
public function journal()
{
return $this->belongsTo(Journal::class);
}
}
控制器:
?php
namespace App\Http\Controllers;
use App\Authorizable;
class HealthController extends Controller
{
use Authorizable;
public function index()
{
return view('health.index')
}
}
最后,我在数据库中分配了权限。
权限表
33 view_healths web 2019-06-14 11:21:56 2019-06-14 11:21:56
34 add_healths web 2019-06-14 11:21:56 2019-06-14 11:21:56
35 edit_healths web 2019-06-14 11:21:56 2019-06-14 11:21:56
36 delete_healths web 2019-06-14 11:21:56 2019-06-14 11:21:56
role_has_permissions 表
33 1
34 1
35 1
并且来自用户的 DD 确认我具有管理员角色。
我在这里想念什么?当我访问路线时,我得到:
此访问未经授权
大概是因为我没有正确的权限?