How do I redirect a user on login/registration based on a condition on the authenticated user?
What I'm trying to do is redirect a user if they are a counsellor to one route, if they aren't to another:
SparkServiceProvider.php
public function booted()
{
if(auth()->user()->is_counsellor){
Spark::afterLoginRedirectTo('/timeline');
} else {
Spark::afterLoginRedirectTo('/thoughts');
}
}
Error
Trying to get property 'is_counsellor' of non-object
There has to be a way to override/overrule Sparks redirects in a way that takes into consideration conditions on authentication right? I've seen many unanswered threads about this, so I'm pretty confused