I'm attempting to limit access to a specific resource HealthController
I am using Spatie and Laravel. I have set up my routes such as this. Note the posts route works fine, but the health one does not do as I want.
Routes:
Route::group( ['middleware' => ['auth']], function() {
Route::resource('users', 'UserController');
Route::resource('roles', 'RoleController');
Route::resource('posts', 'PostController');
Route::resource('health', 'HealthController');
});
Model:
<?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);
}
}
Controller:
?php
namespace App\Http\Controllers;
use App\Authorizable;
class HealthController extends Controller
{
use Authorizable;
public function index()
{
return view('health.index')
}
}
and finally, I have assigned the permissions in the database.
Permissions table
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 table
33 1
34 1
35 1
and a DD out of the user confirms that I have the Admin role.
What am I missing here? When I visit the route I get:
This access is unauthorized
Presumably because I don't have the correct permissions?