Created
December 28, 2016 20:52
-
-
Save omurphy27/5b0ac2d5d6cc02ff0dfa36b099ea3eac to your computer and use it in GitHub Desktop.
Laravel - Determine if an Eloquent Collection from Get has results or is empty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$result = Model::where(...)->get(); | |
if ($result->first()) { } | |
if (!$result->isEmpty()) { } | |
if ($result->count()) { } | |
if (count($result)) { } | |
// see here: http://stackoverflow.com/questions/20563166/eloquent-collection-counting-and-detect-empty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment