redirect user after Log in to different pages according to its type LARAVEL 5.4
i ve tried this method on my LoginController and it did not work it still redirect me to my
user.home View that i ve deleted .
obviously i got this error
InvalidArgumentException in FileViewFinder.php line 137:
View [user.home] not found.
<?php
public function authenticated(Request $request, $user)
{
$type = $user->userable_type ;
switch ($type)
{
case 'Student':
return redirect()->intended('/Student/Home');
break;
case 'Teacher':
return redirect()->intended('/Teacher/Home');
break;
case 'Company':
return redirect()->intended('/Company/Home');
break;
}
}
i don't think its this code, rather middleware is hijacking the request.
a common culprit is the redirectIfAuthenticated middleware. in there you will see /home. change that to some random string and see if you get sent there.
Snapey Yes Every request actually it s redirected I know that it s a Bad approach but i did not find any solution else !
jlrdw yes i ve added a default File & add some Comments for Reusable Code !
if someone can help me to not edit the middleware File & everything work as I want it s gonna Be awesome
you were following the right approach in the first place. I suggested a way to identify that it was the guest middleware causing the issue, but I cannot see that you tried it?