I've created an anonimus global scope in the users model as below in order to get only public users in the frontend:
protected static function boot()
{
parent::boot();
static::addGlobalScope('is_public', function(Builder $builder) {
$builder->where('is_public', '=', 1);
});
}
But... when i need to perform the login in the backend i need of course to check for not-public users so i need to exclude the global scope.
Is this possibile using the default AuthController of laravel?
Many Thanks!!
You just need to create two Models - one without global scope (i.e. AuthUser) and another with the global scope that extends the first one (i.e. User).
Then you can use AuthUser for authentication And User everywhere else.
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