当我尝试分页时,我得到了一个异常调用未定义的方法App\Clothings::links(((View:D:\work\Laravel\winter\resources\views\pages\home.blade.php(。我的数据在blade文件中查看,但由于上述异常,我无法进行分页。请帮助
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]);
}
}
在刀片文件中。
<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()}}
您需要处理空集合
@unless (count($renimage))
{{$renimage->links()}}
@endunless