vendredi 29 janvier 2016

laravel 5 pagination issue 5

I'm trying to build a website with laravel and I'm using pagination to show the result of searching. when I click on search button , it works but when I click on the next page of the pagination ,all values ​​of search form disappear and there is no result in searching is there anyone to help؟

route.php

Route::get('search', 'searchController@index');//return search view
Route::post('misearch', 'searchController@search');// return result 
Route::resource('misearch', 'searchController@search');// for pagination

searchController.php

$results =  Mod_ads::where(function($query){
$ins_brand = Input::has('ins_brand')? Input::get('ins_brand'):null;
$min_price = Input::has('min_price')? Input::get('min_price'):null;
$max_price = Input::has('max_price')? Input::get('max_price'):null;
$ins_color = Input::has('ins_color')? Input::get('ins_color'):null;


if (isset($min_price) && isset($max_price)) {
    $query -> where('ads_fie_insprice', '>=', $min_price)->
        where('ads_fie_insprice', '<=', $max_price);
    }


    if ($ins_brand == '0') {
        unset($ins_brand);
    }else{
        $query->where('ads_fie_insbrand', '=', $ins_brand);
    }


    if (isset($ins_color)) {
        $query->where('ads_fie_inscolor', 'LIKE', '%'.$ins_color.'%');
    }


        })->paginate(2);
        $link = str_replace('/?', '?', $results->render());
        return View::make('search', compact('results', 'link'));

search.blade.php

@if(isset($results))
  @foreach($results->getCollection()->all() as $result) 
      {{ $result->ads_fie_insbrand }}
      {{ $result->ads_fie_insprice }}
      {{ $result->ads_fie_inscolor }}
  @endforeach 
@endif 

                @if(isset($results))
                 {!! $link !!} 
                @endif



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire