调用未定义的方法Laravel \ Lumen \ Routing \ Router :: where()

时间:2018-02-07 03:40:10

标签: lumen

如何在where

中使用Lumen方法
Route::get('/talent/{id}', 'TalentController@talent')->where('id', '[0-9]+');

给我这个错误:

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

使用php 7"laravel/lumen-framework": "5.5.*"

1 个答案:

答案 0 :(得分:6)

Lumen使用的路由器与Laravel不同。

对于流明,正则表达式约束直接在路径参数定义中。您的代码看起来像:

$router->get('/talent/{id:[0-9]+}', 'TalentController@talent');

您可以在the documentation here中了解有关流明路由和约束的更多信息。