【发布时间】:2017-01-22 10:32:05
【问题描述】:
我正在尝试实现如下所示的 url 结构。
- example.com/clients/{client_id} //完成
- example.com/clients/{client_id}{project_id} // 问题
错误是缺少 [Route: clients.show_project] [URI: clients/{client}/{project_id}] 的必需参数。
Route::group(['prefix' => 'clients', 'as' => 'clients.'], function () {
Route::get('/', [
'uses' => 'ClientsController@index',
'as' => 'index',
]);
Route::get('/create', [
'uses' => 'ClientsController@create',
'as' => 'create',
]);
Route::post('/store', [
'uses' => 'ClientsController@store',
'as' => 'store',
]);
Route::group(['prefix' => '{client}', '__rp' => ['menu' => 'clients']], function () {
Route::get('/', [
'uses' => 'ClientsController@show_client',
'as' => 'show',
]);
});
Route::group(['prefix' => '{client}/{project_id}'], function () {
Route::get('/', [
'uses' => 'ClientsController@show_project',
'as' => 'show_project',
]);
});
});
正在观看
<a href="{{ route('clients.show_project', $task->client_id, $task->project_id)}}">{{ $task->title }}</a>
控制器
public function show_project($client, $project_id)
{
$project_threads = Project_Threads::where('project_id', $project_id)->get();
return $project_threads;
}
【问题讨论】:
-
你能把
ClientsController@show_project的代码放上来 -
更新了我的代码。@Bara'ayyash
标签: php laravel laravel-5.3