If the database query does not find suitable results, it returns null . Therefore...
$patient = Patient::where('name','=','Bob')->first(); if ( is_null($patient) ) { App::abort(404); }
(Note: in the original question, you forgot ->first() (or ->get() ) in your request. Do not forget about it, otherwise you will get an Eloquent object instead of the result.)
Jake wilson
source share