J
J
jazzus2018-12-26 13:01:15
Laravel
jazzus, 2018-12-26 13:01:15

Why does Auth give different users?

Faced with an inexplicable phenomenon.
dd(Auth::user());
Gives the user with id 24 (correct).

$user = Auth::user()
                    ->withCount('lists')
                    ->first();

                    dd($user);

Gives a user with id 1 (wrong)
And so for all authorized users.
update
affects ->first(); apparently gives the first user with the first. I wonder why. After all, Auth must make a sample before the first

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Talalaev, 2018-12-26
@jazzus

$user = User::withCount('lists')
                    ->find(Auth::id());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question