Here is my code in the routes.php file:
Route::auth();
Now I need to put a middleware on the way of that route. Something like this:
Route::auth()->middleware('setLang');
But in this case, it throws this error:
FatalErrorException in routes.php line 43: Call to a member function middleware() on null
How can I fix it?
To make it work, you first need to register middleware.
After that use group() method to set middleware property:
Route::group(['middleware' => 'setLang'], function () {
Route::auth();
});
If you still get Class not found error, try to run composer dumpauto command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With