s0hno s0hno - 5 months ago 31
PHP Question

Laravel paginate order by

What should I do to pass the values ‚Äč‚Äčthat you order by in patinate?

routes.php

$ondata = DB::table('official_news') -> orderBy('created_date', 'desc') -> get() -> paginate(7);
return View::make('main',array('ondata' => $ondata));


error

Call to a member function paginate() on a non-object


I need your help

Answer

This should do the trick:

$ondata = DB::table('official_news')->orderBy('created_date', 'desc')->paginate(7);