我正在尝试实现如下的url结构。
错误是缺少[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;
}
答案 0 :(得分:1)
问题出在你看来。你必须在route()
的数组中传递params。试试这个:
<a href="{{ route('clients.show_project', [$task->client_id, $task->project_id])}}">{{ $task->title }}</a>