How to check if query returned any records using first with Laravel Eloquent ORM

Although this may be easy to some, for beginners it can be like hell looking for the right answer. Heck, I do not know if I do have the GOOD right answer, but this works for me.

$ocd = _Ocd::where("nutcase", 4)->first();
if (count($ocd) >= 0){ echo "No record found";
}else{ echo "Found"; }

I wish Laravel documentation was better.

Exit mobile version