This might be a simple question, but I cannot figure this out. I am trying to get a user by email using:
$user = User::whereEmail($email)->get();
But this is returning an array (of dimension 1) of $users. So If I want to get the name, I have to do $user[0]['first_name']
.
I tried using limit(1)
or take(1)
, or even using ->toArray()
but there was no difference.
What am I doing wrong?
Simply use this:
$user = User::whereEmail($email)->first();