gpt4 book ai didi

Laravel 组路由问题

转载 作者:行者123 更新时间:2023-12-02 01:30:40 25 4
gpt4 key购买 nike

在没有 ->where('id', '[0-9]+'); 的路由中使用约束参数时 Laravel 路由问题工作,但我需要添加这个。

Route::group(['prefix' => '/{id}'], function () { 
Route::post('/edit', 'User\InstituteController@editInstitute');
})->where('id', '[0-9]+');

导致下面的错误

Call to a member function where() on a non-object

最佳答案

这是正确的方法。这样你就可以定义多个 where 条件。未经测试,但希望您能理解。

Route::group([
'prefix' => '/{id}',
'where' => [
'id' => '[0-9]+'
]
],
function () {
Route::post('/edit', 'User\InstituteController@editInstitute');
});

关于Laravel 组路由问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34352898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com