This should do the trick:
$ondata = DB::table('official_news')->orderBy('created_date', 'desc')->paginate(7);
It will be better if you order it by the id because it is going to be faster from the database.
$posts = Post::orderBy('id', 'desc')->paginate(6);
https://laracasts.com/discuss/channels/laravel/combining-paginate-with-orderby
It works fine for Laravel 5.1.
You can use something like this in your controller file.
$transactions = Transaction::orderBy('name')->paginate(10);
return view('index', compact('transactions'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With