Reputation: 852
I use the following middleware in routing Laravel:
Route::group(['prefix' => 'api/'], function() {
Route::resource('admin', 'adminController')->middleware('auth');
Route::resource('profile', 'profileController')->middleware('role');
});
I get this error when i call 'admin' or 'profile' path in URL
Upvotes: 5
Views: 16277
Reputation: 51
In Laravel 8.x you can solve this problem with:
Route::group(['middleware' => 'auth','middleware' => 'role'], function () {
..........
});
Upvotes: 0
Reputation: 63
Simply reverse the order:
Route::middleware('scope:clock-in')->resource('clock', 'ClockController');
As lagbox stated:
Route::resource()
does not return anything.
However middleware does.
Upvotes: 2
Reputation: 583
Use this
Route::prefix("/dashboard")->middleware(['first','second'])->group(function(){
});
Upvotes: 8
Reputation: 50501
It is because Route::resource()
does not return anything. Its void. It doesn't return an object.
Laravel 5.4 - Illuminate\Routing\Router@resource
In Laravel 5.5 (in development), Route::resource()
will be returning an object for fluently adding options to.
Upvotes: 7
Reputation: 3040
Most likely your resource controller is not resolving to an actual controller. Some things to check
Upvotes: 0