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);



YOUR REACTION?



Facebook Conversations



Disqus Conversations