Answers for "laravel check for empty model"

PHP
3

laravel check if object empty

@if(!$contacts->isEmpty())
//do something
@else
You dont have contacts
@endif
Posted by: Guest on July-13-2020
1

how to check if eloquent result is empty

Note:- Credit for this result goes to Alberto Peripolli. Copied from his Grepper.
if ($result->first()) { } 
if (!$result->isEmpty()) { }
if ($result->count()) { }
if (count($result)) { }
Posted by: Guest on September-05-2020

Browse Popular Code Answers by Language