1
votes

When i try to paginate i got an exception Call to undefined method App\Clothes::links() (View: D:\work\Laravel\winter\resources\views\pages\home.blade.php).my data is view in the blade file but i am not been able to do pagination because of the above exception.please help

public function images(){
    if(auth::check()){
        $user = Auth::user();
        $renimage = Clothes::orderBy('id','desc')->paginate(3); 
        $cart = cart::where('user_id',$user->id)->get();
        $cart_added=count($cart);

        return view('pages.home',['renimage'=>$renimage,'google_avater'=>$user,
        'cart_added'=>$cart_added]);
    }
}

In the blade file.

          <div class="container" style="margin-top:50px;margin-bottom:50px">
          <div>    
          @foreach ($renimage as $renimage)
          <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
         <div class="hovereffect">
        <img class="img-responsive" src="{{asset('upload/'.$renimage->img) }}" alt="">
         </br>
                          <div class="overlay">
            <h2>{{$renimage->name}}</h2>
       <h3 style="color: white;padding-top: 70px;">{{'$'.$renimage->price}}</h2>
       <a class="info" href="{{ route('product',['id'=>$renimage->id])}}" style="margin-top: 
     20px;">Buy Now</a>

      </div>
    </div>
  </div>
  @endforeach
  {{$renimage->links()}}
1

1 Answers

0
votes

you need to handle empty collections

   @unless (count($renimage))
      {{$renimage->links()}}
   @endunless