There's findOrFail()
method which throws 404 if nothing was found, e.g.:
User::findOrFail(1);
How can I find an entity by custom column or fail, something like this:
Page::findBySlugOrFail('about');
Try it like this:
Page::where('slug', '=', 'about')->firstOrFail(); // or without the explicit '=' Page::where('slug', 'about')->firstOrFail();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With