What is $this->user ?
It's an already loaded user? a relationship? An empty object of type User?
Normally, in this case you should be doing:
$userInfo = User::with('admin')->where('username', $username)->first();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So I am running this eloquent query:
$userInfo = $this->user->where('username', $username)->with('admin')->first();
When I do a dd() on $userInfo, it shows that the relations show null. I did a
dd(DB::getQueryLog());
Added screenshots below. https://potentdevelopment.com/pictures/sql-dump.png https://potentdevelopment.com/pictures/result-dump.png
And it shows that the query and the values passed are correct. Any help or clue would be appreciated.
Thanks!
So it was actually me being stupid. In the end, there wasn't anything wrong with the code. I was looking at the wrong DB via MySQL Workbench. Grrrrrr
Thank you all for your help!
Please or to participate in this conversation.