Level 8
just use this syntax. User::find($user_id); u dont need first( ) method since find method only return single collection so u dont need it. first() method is used to reterive single object from multiple collections.
1 like
I have a users model on which I used to call
User::find($user_id)->first();
But against the expected result of getting the user with the id, I was always getting the first user (user_id=1).
It does not make any logic to me as no exception was triggered and to the application was getting a valid user in the end.
I think this is a bug.
$ php artisan --version
Laravel Framework version Lumen (5.1.3) (Laravel Components 5.1.*)
Please or to participate in this conversation.