如何验证路线(流明)

时间:2018-02-16 03:53:10

标签: laravel lumen

如果我不使用验证确实有效:

'uses' => 'ArticleController@talentPagination']

工作:

$router->get('/api/talents/{id:[0-9]+}/articles', [function (Request $request) {
    $this->validate($request, [
        'per_page'     => 'Required|integer|min:1',
        'page'         => 'Required|integer|min:1',
        'published_at' => 'Required|date_format:Y-m-d\TH:i:s\Z'
    ]);
});

但是,如何在通过验证后指定控制器和操作?

我尝试使用'使用',但它会跳过验证,例如:

$router->get('/api/talents/{id:[0-9]+}/articles', [function (Request $request) {
    $this->validate($request, [
        'per_page'     => 'Required|integer|min:1',
        'page'         => 'Required|integer|min:1',
        'published_at' => 'Required|date_format:Y-m-d\TH:i:s\Z'
    ]);
}, 'uses' => 'ArticleController@talentPagination']);

有没有办法可以验证它然后将其路由到控制器操作?

Lumen ver: 5.6
Php: 7.1.9

0 个答案:

没有答案