0
votes

First query show demanded record but when I click page2 it show all record not query demanded record. My lawyer table is

enter image description here

route: Route::get('Search','solicitorClient@search')->name('search');

$search=DB::table('lawyer')
                ->where([
                    ['specialization','LIKE', '%'.$request->expertise.'%'],
                    ['location','LIKE','%'.$request->city.'%'],
                    ['zip_code','LIKE','%'.$request->zip_code.'%']
                ])->orderBy('payment_price','desc')
                ->paginate(3);

I desired to show only lawyer record which is specialization in 'copyright' but i click page2 its show all record other than 'copyright' specialization page 1 url: http://localhost/solicitor/public/Search?expertise=Copyright&city=&zip_code= when i click on page 2 its url change to http://localhost/solicitor/public/Search?page=2

my query page 2 result

1
Please see how to create an minimal reproducible example. As-is, we don't have nearly enough information about your code in order to help.random_user_name

1 Answers

0
votes

Look at your URLs in both pages again. I think it happens because you are getting expertise parameter from your URL and it doesn't appear on your page 2.

try this on your view:

{{ $search->appends(['expertise' => $expertise])->links() }}

And in your controller:

$expertise = $request->expertise;
return view('search.view', compact('search', 'expertise'));