How can I use where
method in Lumen
Route::get('/talent/{id}', 'TalentController@talent')->where('id', '[0-9]+');
Gives me this error:
(1/1) FatalThrowableError
Call to undefined method Laravel\Lumen\Routing\Router::where()
Using php 7
and "laravel/lumen-framework": "5.5.*"
Lumen uses a different router than Laravel does.
For Lumen, the regex constraint is directly in the route parameter defintion. Your code would look something like:
$router->get('/talent/{id:[0-9]+}', 'TalentController@talent');
You can read more about Lumen routing and the constraints in the documentation here.
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