Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda