Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined method Laravel\Lumen\Routing\Router::where()

Tags:

lumen

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.*"

like image 641
whitesiroi Avatar asked Dec 23 '22 10:12

whitesiroi


1 Answers

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.

like image 175
patricus Avatar answered Mar 02 '23 14:03

patricus