如何检查laravel中是否使用过分页 [英] How to check if used paginate in laravel
本文介绍了如何检查laravel中是否使用过分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自定义视图,在某些功能中,我使用了paginate
,而其他一些功能中我没有使用paginate
.现在如何检查我是否使用了paginate
?
I have a custom view and in some functions, I used paginate
and other functions I don't use paginate
. now how can I check if I used paginate
or not ?
@if($products->links())
{{$products->links()}}
@endif // not work
我当然知道我可以将变量用作true false来检查它,但是有没有任何本机函数来检查它?
of course that I know I can use a variable as true false to will check it, But is there any native function to check it ?
推荐答案
这非常有效.检查$products
是否是Illuminate\Pagination\LengthAwarePaginator
的实例,然后显示分页链接.
This works perfectly. Check if $products
is an instance of Illuminate\Pagination\LengthAwarePaginator
then display the pagination links.
@if($products instanceof \Illuminate\Pagination\LengthAwarePaginator )
{{$products->links()}}
@endif
这篇关于如何检查laravel中是否使用过分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文