Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda