Hey @nilo
Yes you can specify your own logic for resolving route params to a model.
Check out the documentation below. If you need any further assistance, just reply here.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Is there a way to manually run a string through Laravel's route parameter binding? Basically I need to create routes dynamically.
For example - give the route:
Route::get('/posts/{slug}', 'SomeController@show');
I'd like to take it one step further and parse the slug as it may contain additional parameters.
// User visits
// example.com/posts/foobar-something-bizbaz
// Our dynamic slug looks like this
$slug = "foobar-{word}-bizbaz";
// In this case the value of word is
$word = "something";
// Another post could have a different slug
// example.com/posts/{another_word}-yada-yada
In the controller or middleware, I'd like to run the slug through whatever Laravel parses routes with to extract the value of {word} and make a query using that value. I could probably cobble together a regex, but Laravel already does exactly what I need.
Any suggestions?
Please or to participate in this conversation.