Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Auto-Redirect to Correct Area after Login/Register

Premium
2 min read

Comments & Discussion

RA
Richard A. Hoyle ✓ Link copied!

I setup the larastan plugin in this project and I am getting 1 error dealing with the (int) that we setup in hear

return match ((int)$this->role_id)

$ ./vendor/bin/phpstan analyse Note: Using configuration file C:\xampp\htdocs\awi_projects\project-1\phpstan.neon. 42/42 [============================] 100%


Line Models\User.php


49 Match expression does not handle remaining values: int<min, 0>|int<4, max>


[ERROR] Found 1 error

have a suggestion as to how to fix this ?

maby using 0,1,2 instead ?

J
jvieyral ✓ Link copied!

I also had to add the redirection to that route in the 'RedirectIfAuthenticated' middleware.

RA
Richard A. Hoyle ✓ Link copied!

just what did you add please give example

RA
Richard A. Hoyle ✓ Link copied!

I am haveing NO issue when I am using laravel 10.8.0

J
jvieyral ✓ Link copied!

Yes, sorry Im using laravel 9.19 So I had to add this line of code in 'RedirectIfAuthenticated':

foreach ($guards as $guard) { if (Auth::guard($guard)->check()) { //return redirect(RouteServiceProvider::HOME); return redirect()->route( auth()->user()->getRedirectRouteName() ); } }