2016-05-23 14 views
0

私はEloquent whereRawとpaginatateの結果を使用するSQL検索を使用しています。Laravel whereステートメントとページ番号

Proplem:結果がページ分割されていると私は、次のページに移動した場合の結果が消えてしまいますし、それだけでlaravelのページネーションbacause「すべてを選択」する唯一の送信ページ= GETリクエストを?。

コード:

laravelだけのページで改ページを生成しますので、私はすべての入力がなくなっている次のページに移動するとき
if (Input::has('city')) { 
     $query .= ' and city = '.Input::get('city'); 
    } 
    if (Input::has('area')) { 
     $query .= ' and area = '.Input::get('area'); 
    } 
    if (Input::has('sub_location')) { 
     $query .= ' and sub_location = '.Input::get('sub_location'); 
    } 
    if (Input::has('rent')) { 
     $query .= ' and rent = '.Input::get('rent'); 
    } 
    if (Input::has('price_min') && Input::has('price_max')) { 
     $query .= ' and price < '.Input::get('price_max').' and price >'.Input::get('price_min'); 
    } 


    $listings = ListingDB::whereRaw($query)->paginate(5); 


    return View::make('page.index')->with('title','Home')->with('listings',$listings); 

はそう=変数をGET、私はそれをどのように解決することができますか??

ありがとうございました。

答えて

1

あなたはあなたがアペンドメソッドを使用してページネーションリンクのクエリ文字列に追加することができます。たとえば、追加するページネーションリンク

に追加するページネーションリンク

{!! $listings->appends(Input::all())->render() !!} 
0

」に文字列を照会追加することができます& sort =各ページネーションリンクに投票すると、次のように追加する必要があります。

{!! $ sort-> appends(['sort' => 'value']) - > links()!!}

都市と賃貸検索を適用している場合は、このようなページ区切りリンクに追加する必要があります

{!! (都市名=> 'ロンドン'、 '家賃' => 5000)) - > links()!!}

これはあなたの問題を解決します。

関連する問題