I would like to try to append a get parameter to paginate URL in some way. But it does not work.
I really want to add ?year=XXXX
to this Query string in pagenate links
When any of these 1,2,3~11 buttons is clicked ,?year=XXXX will be removed.
public function list(Request $request)
{
$year = $request->year;
$companies = Company::orderBy('id', 'DESC')->paginate(15);
$data = ['companies' => $companies ,'pagenate_params' => ['year' => $year]];
return view('list', $data);
}
Blade
@foreach ($companies as $company)
<a href={{ route('next',['id' => $company->id ,'year' => $year])}} {{$year}}</a>
@endforeach
{{ $companies->appends('year' => '2022')->links() }}