Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rpm192's avatar

Check if Eloquent query returned anything

When I use the following query:

$user_id = auth()->user()->id;
$profiles = Profile::where('user_id', '=' ,$user_id)->get();

It always returns this when I use print_r to check:

Illuminate\Database\Eloquent\Collection Object ( [items:protected] => Array ( ) ) 

This means that I cannot use count, because it will always return true.

@if(count($profiles))
    not empty
@else
    empty
@endif

Am I doing something wrong?

0 likes
1 reply
rpm192's avatar
rpm192
OP
Best Answer
Level 1

Nevermind, my IF statement was backwards in my local project..

Please or to participate in this conversation.