Instead of manually writing Post::findOrFail($id) in every controller method, just type-hint the Model in your method signature! Laravel automatically fetches the matching record from the database—or returns a clean 404 if it doesn't exist.
ADVERTISEMENT