Wednesday, March 8, 2017

Method appends does not exist Laravel

I want to select all hotels where minrate between 0 and 49 it marche perfectly , but when i want to select all hotels where minrate between 0-49 and 50-99 It is you to say when it enters the loop "for" it return this error

ErrorException in Macroable.php line 74: Method appends does not exist. (View: C:\xampp\htdocs\elasticsearch\resources\views\presult.blade.php) (View: C:\xampp\htdocs\elasticsearch\resources\views\presult.blade.php)

Function Laravel

public function pricefilter(Request $request)
    {
         $query = Input::get('query', false);
       $brans = request()->priceFilter;
         $books = new Collection(); 
if(!empty($brans))
        { 
            $product = "";

foreach($brans as $data){
               $minMax = explode("-",$data);


                $product[] = Afica::search()
                    ->multiMatch(['name','city_hotel'], $query, ['fuzziness' => 'AUTO'])
                    ->filter()
                    ->range('minrate',['from'=>$minMax[0],'to'=>$minMax[1]])
                    ->paginate(26)
                    ->appends('priceFilter' , request('priceFilter'));




         }
          $books= $product[0];
          for($i=1;$i<count($product);$i++){
              $books=$books->union($product[$i]);


          }
         }
        else 
        {
               $books = Afica::search()
            ->paginate(26);


        }
        if ($request->ajax())
        {
                return view('presult', compact('books'));
        }
        return view('welcome',compact('books')); 

    }

**View presult **

 <!--deal-->    
            <?php $myArray = array();?>

            @if  (empty($myArray))

            @foreach($books as $Afica)
            <?php $collection = collect($Afica);?>
            <article class="one-third">
              <figure><a href="#" title=""><img src="" alt="" style="height: 215px!important;" /></a></figure>

              <div class="details">

                <h3>}
                  <span class="stars">

                      <?php 

                      for ($i=1 ; $i<= $collection->get('class') ; $i++) 
                      {
                      echo ' <i class="material-icons">&#xE838;</i>';
                      }

                  ?>
                  </span>
                </h3>
                <span class="address">},}  <a href="">Show on map</a></span>
                <span class="rating">}</span>
                <span class="price">Max rate  <em>$ }</em> </span>
                <span class="pricee">Min rate  <em>$ }</em> </span>
                <div class="description">
                  <p>}<a href="hotel?query= $collection->get('name')">More info</a></p>
                </div>   
                <a href="}" title="Book now" class="gradient-button">Book now</a>
              </div>
            </article><?php $myArray[] =  $collection->get('id');?>

            <!--//deal-->
            @endforeach

           @endif




            <!--//bottom navigation-->
             <div class="bottom-nav">
            <a href="#" class="scroll-to-top" title="Back up">Back up</a> 
            <div class="pager">
            <?php $query=Input::get('query', '');?>
            @if($query == "")
          <span><a href="?page=1">First Page</a></span>
            @else
         <span><a href="?query=<?php echo $query?>&page=1"=>FirstPage</a></span>
         @endif
       {!! $books->appends(['query' => Input::get('query')])->render() !!}
       @if($query == "")
          <span><a href="?page={!! $books->appends(['query' => Input::get('query')])->lastPage() !!}">Last Page</a></span>
            @else
         <span><a href="?query=<?php echo $query?>&page={!! $books->appends(['query' => Input::get('query')])->lastPage() !!}">Last Page</a></span>
         @endif
            <!--bottom navigation-->
              </div>
         </div>    
            <!--//bottom navigation-->



via koora et film Tv

Advertisement