need to ask about error, when I tried to redirect my logout
This is UserController:
public function logout()
{
    Auth::logout();
    return redirect()->route('auth/login');
}
This is my routes:
Route::get('/', function () {
    return view('welcome');
});
// Authentication routes...
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');
Route::get('testing', 'UserController@test');
Route::get('logout', 'UserController@logout');
I think, taht everything is ok on routes and I defined login properly (like a Laravel documentation)
but it still take this error:
InvalidArgumentException in UrlGenerator.php line 306:
Route [auth/login] not defined.
Can you please what is wrong? Did I make any mistake?
Thanks a lot, have a nice day!
The route method expects a name, not a URI. So you need to name your route.
Like this:
Route::get('auth/login', ['as' => 'login', 'uses' => 'Auth\AuthController@getLogin']);
Or:
Route::get('auth/login', 'Auth\AuthController@getLogin')->name('login');
Now you can call return redirect()->route('login');
See the docs for Named Routes.
Alternatively, you can just provide the URI in the redirect method like this:
return redirect('auth/login');
Though this would break if you ever change this endpoint. I'd recommend naming your routes and using those in your code.
change your return redirect()->route('auth/login'); to 
return redirect('auth/login');
or return Redirect::to('auth/login');
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