Laravel-permission: Target class [role] does not exist on laravel 6.0.3

Created on 18 Sep 2019  路  1Comment  路  Source: spatie/laravel-permission

What is this error?
I face this error when user authenticate and redirect to admin route.
and gave this error. even if role exist.

Here is my route

Route::group(['domain' => '{subdomain}.localhost', 'middleware' => 'checkdomainanddatabase'], function () {
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home'); 
Route::group(['prefix'=> 'admin', 'middleware' => ['role:admin']], function ($subdomain) {
        Route::get('/dashboard', function ($subdomain) {
            return "writer idr agya hai";
        })->name('admin.dashboard');
    });
});

Here is my login controller

$role = Auth::user()->getRoleNames();
        // Check user role
        switch ($role[0]) {
            case 'writer':
                return route('admin.dashboard');
                break;
            default:
                return '/home';
                break;
        }
support

Most helpful comment

Without seeing more code, I'm guessing maybe it's referring to the role:admin middleware not being defined in your app.

>All comments

Without seeing more code, I'm guessing maybe it's referring to the role:admin middleware not being defined in your app.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

wreighsantos picture wreighsantos  路  4Comments

hosseinnedaei picture hosseinnedaei  路  3Comments

devingray picture devingray  路  3Comments

dylangeorgeharbour picture dylangeorgeharbour  路  3Comments