I would say: if( $sale )
Or being pessimist: if( !$sale ) throw new Exception('Alias ' . $alias ' . does not exist');
But i'm all ears to alternative ways!
What about firstOrFail() and then handle ModelNotFoundException?
I have found two ways to do that :
if($sale->isEmpty()) : but only available for a get() and not for a first()
and
count($sale) : if > 0, $sale contains a result
$user = whatever;
if ( ! $user) {
bail here
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community