Skip to content
Advertisement

Laravel 5 Property [userType] does not exist on this collection instance

I keep getting property [userType] does not exist error when Im trying to make log in condition here is my Controller code below. I also tried to make Auth controller but I just keep getting the same error from this.

JavaScript

and here is my model code

JavaScript

anyway on how can I fix this? Please show me the correct way to create a redirect in login because I just want to create a login with admin, user, and guest mode.

Advertisement

Answer

Its very clear erorr

JavaScript

in redirectTo method you are accessing $user = User:all(); instead one record .It may be Auth::user() or User::find($id)

JavaScript

all return multiple records so you cant access userType directly

Instead of using redirectTo to you can use authenticated method

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