2,020
views
views
Eloquent has quite a few functions that combine two methods, like “please do X, otherwise do Y”.
findOrFail()
Eloquent has quite a few functions that combine two methods, like “please do X, otherwise do Y”.
Instead of:
$user = User::find($id);if (!$user) { abort (404); }
Do this:
$user = User::findOrFail($id);
Comments
0 comment