0

I would like to try to append a get parameter to paginate URL in some way. But it does not work.

enter image description here

enter image description here

I really want to add ?year=XXXX to this Query string in pagenate links

enter image description here

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() }}
flow Stack
  • 19
  • 1
  • 6
  • 1
    I take it you mean the `year` isn't getting added to the query string? Can you also explain what you mean by "*it does not work*", i.e. does it cause an error, does it display the wrong year, does it not display a year etc.? – Rwd Dec 07 '21 at 13:36
  • Does this answer your question? [How to automatically append query string to laravel pagination links?](https://stackoverflow.com/questions/24891276/how-to-automatically-append-query-string-to-laravel-pagination-links) – Rouhollah Mazarei Dec 07 '21 at 13:53
  • If it possible,I don't want to use Ajax. – flow Stack Dec 08 '21 at 04:36

0 Answers0