Laravel 5.2 with pagination

4

I have the following function inside the controller

public function home()
{
    $igrejas = Igreja::paginate(3);
    $igrejas->setPath('igrejas');
    return view('admin/igrejas/home')->with('igrejas', $igrejas);
}

I need to be returned beyond pagination, by creation order, that the last page will appear on the first page. As the system is in the last pages the last records, I need the reverse.

    
asked by anonymous 02.08.2016 / 20:19

1 answer

4

A small change:

...
Igreja::orderBy('id', 'DESC')->paginate(3);
...

Note that I am assuming that there is a id auto-increment column in this table, if there is no order in the column you would like

    
02.08.2016 / 20:29