mpgn mpgn - 11 months ago 127
PHP Question

Laravel 4 paginate and orderBy

Normaly I call my database like this :

$data = array(
'one' => MyORM::paginate($this->per_page),

);
return View::make('project.index')->with($data);


But I also want to use an OrderBy so I can use:

$data = array(
'test' => MyORM::orderBy('date', 'DESC')->get(),
);
return View::make('project.index')->with($data);


But I don't know how I can "merge" the two codes?

I can also use :

$data = array(
'test2' => DB::table('martialp')
->orderBy('date', 'DESC')
->paginate(4)
);


But my class
MyORM
for exemple is useless with this previous code.

Answer Source
$data = MyORM::orderBy('date', 'DESC')->paginate(15);

return View::make('project.index', compact('data'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download