Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Laravel 5.3 Post search with session for complex search

i have a search routes like that

Route::post('search', 'SearchController@index');
Route::get('search', 'SearchController@index');

now i'm searching the result from home page form etc 6 form fields then it redirect me on the search page with result but when i click it second time on pagination page it does not work for me.i'm using session in it for remember data that i post for the home. i can search also on this page if i have session then i read second condition in my case.

Controller is below

public function index(Request $request)
    {

    if( Request::get('select_menu') !='' ){

                $conditions = array();
                $conditions['city'] = Request::get('city');
                $conditions['area'] = Request::get('area');
                $conditions['purpose'] = Request::get('status');
                $results = Property::where($conditions)->whereBetween('price', array(1000, 10000))->paginate(6);
                Session::set('formDataSession', $conditions);

            }
        elseif(Session::has('formDataSession')){

                $getSession = Session::get('formDataSession');

                $conditions = array();
                $conditions['city'] = $getSession['city'];
                $conditions['area'] = $getSession['area'];
                $conditions['purpose'] = $getSession['purpose'];
                $results = Property::where($conditions)->whereBetween('price', array(1000, 10000))->paginate(6);

            }
    return view('search', array('page' => 'search','results'=>$results));
}
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!