Say I've got this set in RouteServiceProvider::boot()
:
$router->bind('user', function ($value) {
return \App\Models\User::where('name', str_slug($value))->first();
});
And I have this route:
Route::get('/{user}', ['as' => 'profile', 'uses' => 'ProfileController@getProfile']);
But the unfortunate structure of the website means that the routing rules that would check this are at the same level of other rules which are inserted statically. If a model doesn't exist, it would be ideal for it to skip the routing rule in question.
I've tried shifting the route that needs this change behind every other route, but alas, the problem persists. It tries to match this route no matter what.
What do I need to do to resolve this? I cannot change the structure of the whole web app, but I still need dynamic routing at this path level.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire