Have you tried removing the Element typehint in the show method to prevent the implicit model binding.
public function show($elementId) {
if($el = Element::find($elementId) {
} else {
// redirect to search here
}
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey everybody
On my recent pages I decided it's time to go pro :) and since I might not know the correct terminology I bring the code I have tried.
This is my route: The element parameter is actually the primary Id on the table
Route::get('element/{element}/{something}','ElementsController@show');
And this is the method:
public function show(Element $element)
As long as there is a row on the table with that id every thing works fantastic but if the record has been deleted for some reasons I get:
NotFoundHttpException in Handler.php line 113:
No query results for model [App\Element].
On my normal pages - ie not pro style - I would have sent the id rather than the "element" and checked the existence of the id and would redirect the page to search based on {something} part but apparently the error here is thrown somewhere between requesting the route and starting the method. What would you wise guys suggest I should do?
By the way I searched the forum and found similar questions but somehow they didn't help.
Please or to participate in this conversation.