Example of appending to query string (paginator)
public function index()
{
// Validate and use authorization as per your app.
$page = Request::input('page', '1');
$dogsearch = !empty(Request::input('psch')) ? Request::input('psch') : '';
$aval = !empty(Request::input('aval')) ? Request::input('aval') : '';
$dogsch = $dogsearch . "%";
$query = Dog::where('dogname', 'like', $dogsch);
if ($aval == "n") {
$query->where('adopted', '=', 1);
} else if ($aval == "y") {
$query->where('adopted', '=', 0);
}
$dogs = $query->orderBy('lastedit', 'DESC')->paginate(5);
$params = array('psch' => $dogsearch, 'aval' => $aval);
return view('dog.index', compact('dogs', 'params'));
}
Then view (pagination part)
{{ $dogs->appends($params)->links() }}
route:
Route::middleware(['auth'])->group(function () {
Route::get('dog/index', 'DogController@index');
Route::post('dog/index', 'DogController@index');
// other routes
Note: initial search is a post, thereafter is a get request for pagination. I have a video showing this in use, let me know if you want to view it, it's just a simple search example.
Also Pretty URLs is a core concept, you can use route parameters or a query string.
Reference from documentation: https://laravel.com/docs/7.x/routing#route-parameters