laravel if get is empty code example
Example 1: laravel check if laravel query is empty
if ($result->first()) { }
if (!$result->isEmpty()) { }
if ($result->count()) { }
if (count($result)) { }
Example 2: check empty laravel blade
@empty($products)
<p class="bg-danger text-white p-1">product</p>
@else
<p class="bg-danger text-white p-1">no product</p>
@endempty
Example 3: check count in laravel
$wordlist = Wordlist::where('id', '<=', $correctedComparisons)->get();
$wordCount = $wordlist->count();