Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Pagination links vs render

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.

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'));
}

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?

Thanks

like image 926
Rey Norbert Besmonte Avatar asked Oct 24 '17 02:10

Rey Norbert Besmonte


1 Answers

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.

like image 88
fubar Avatar answered Sep 24 '22 23:09

fubar