Skip to content
Advertisement

Laravel Middleware Error – Call to a member function isBasic() on null

I want to check user type when they log in and apply function

In my middleware, I have this code

JavaScript

In my User model, I have this

JavaScript

I have already registered the middleware in Kernel

JavaScript

And I passed it to my LoginController like this

JavaScript

But when it tried to visit the login controller, it says

Call to a member function isBasic() on null

I am a beginner in Laravel and I don’t know what to do

Advertisement

Answer

This seems like a good candidate for the authenticated method of the LoginController which gets called after a user has logged in.

JavaScript

You could even listen for the Auth events if you wanted to, as long as its not a queued listener.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement