我有一个自定义视图,在一些函数中,我使用了paginate
,而其他函数我不使用paginate
.现在我如何判断我是否使用了paginate
?
@if($products->links())
{{$products->links()}}
@endif // not work
当然,我知道我可以使用一个变量作为true false来判断它,但是否有任何本机函数来判断它?
我有一个自定义视图,在一些函数中,我使用了paginate
,而其他函数我不使用paginate
.现在我如何判断我是否使用了paginate
?
@if($products->links())
{{$products->links()}}
@endif // not work
当然,我知道我可以使用一个变量作为true false来判断它,但是否有任何本机函数来判断它?
这很好用.判断$products
是否是Illuminate\Pagination\LengthAwarePaginator
的实例,然后显示分页链接.
@if($products instanceof \Illuminate\Pagination\LengthAwarePaginator )
{{$products->links()}}
@endif