Reputation: 1219
I realize that I can change where my user is directed after login by changing
protected $redirectTo = '/home';
in the LoginController.php
However, I want to check if there are any items in a shopping cart and if so, direct the user to the checkout page. I may also check to see if they have purchased a service that is active and direct them to the dashboard, then anyone else to the homepage.
Anyone know how to apply some logic to the redirection?
Upvotes: 1
Views: 41
Reputation: 163838
You can override sendLoginResponse()
method in app\Http\Controllers\Auth\LoginController.php
to perform the check and redirect to whatever route you want.
Original sendLoginResponse()
method is in vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php
. Copy-paste it to LoginController.php
and then work with it. Do not change anything in an original trait.
Upvotes: 1