when click on sales index page following error show. Missing required parameter for [Route: clients.show] [URI: clients/{client}] [Missing parameter: client]. here is my salescontroller index function code
`public function index()
`` {
$user_id=helper::getDistId();
$sales = Sale::where('dist_id','=', $user_id)->latest()->paginate(25);
return view('sales.index', compact('sales'));
}`
CodePudding user response:
Controller should look like this
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'));
}
And Route in web.php :
Route::get('/clients/{client}', [SalesController::class, 'index'])->name('clients.show');
CodePudding user response:
In your Client index page there must be a href="{{route('clients.show')}}"
inside this you should pass the client id. like href="{{route('clients.show', $client_id)}}"
where $client_id
refers to the id of the client which you want to show.
if its inside foreach loop then may be you can do
@foreach($sales as $sale)
href="{{route('client.show', $sale->id)}}"
@endforeach
hope you get the point.