Laravel分页链接vs渲染 [英] Laravel Pagination links vs render

查看:150
本文介绍了Laravel分页链接vs渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Laravel 5.x已有几个月了,我只是想知道在使用分页时使用链接和渲染之间有什么区别.我做了一些研究,人们以相同的方式使用这两种方法.

I have been working with Laravel 5.x for a few months now and I was just wondering on what is the difference between using links and render when using pagination. I did a few research and people are using the two the same way.

鉴于我有一个从控制器返回的数组变量,因此我将每个视图的分页次数减少为5个.

Given I have a array variable that has been returned from my controller and I would cut the pagination into 5 items per view.

public function index()
{
    $variable = Jobs::getJob()->paginate(5);
    return view('index', compact('variable'));
}

在我的index.blade.php上,我将显示我已摄取的物品

on my index.blade.php I will display the items that I have taken

@foreach($variable as $key => $values)
     //code here
@endforeach

{{ $variable->render() }}
//same result as
{{ $variable->links() }}

我的问题是,两者之间有什么区别?什么时候应该使用一种替代另一种?

My question now is what are the difference between the two and when should one be use instead of the other?

谢谢

推荐答案

links()()方法只是render()()方法.看来它是在Laravel 5.2中引入的.

The links() (source) method is simply an alias for the render() (source) method. It seems it was introduced in Laravel 5.2.

因此,基本上,您所使用的没有什么不同.

So basically, it doesn't make a difference which you use.

这篇关于Laravel分页链接vs渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆