当我单击“销售索引”页面时,会显示以下错误:
缺少路由所需的参数: clients.show缺少参数: client。
下面是我的salescontroller
索引函数代码:
public function index()
{
$user_id=helper::getDistId();
$sales = Sale::where('dist_id','=', $user_id)->latest()->paginate(25);
return view('sales.index', compact('sales'));
}`
发布于 2022-07-28 07:37:37
控制器应该是这样的
public function index($user_id){
$user_id=helper::getDistId();
$sales = Sale::where('dist_id','=', $user_id)->latest()->paginate(25);
return view('sales.index', compact('sales'));
}
以及web.php的路线:
Route::get('/clients/{client}', [SalesController::class, 'index'])->name('clients.show');
发布于 2022-07-28 08:05:53
在客户端索引页面中,必须有一个href="{{route('clients.show')}}"
在其中,您应该传递客户机id。就像href="{{route('clients.show', $client_id)}}"
一样,$client_id
引用您想要显示的客户端的id。
如果它的内部foreach循环,那么可能是您可以做的。
@foreach($sales as $sale)
href="{{route('client.show', $sale->id)}}"
@endforeach
希望你明白重点。
https://stackoverflow.com/questions/73148716
复制相似问题