Question and answer is powered by AnsPress.io
Follow this example code:
<?php User::orderBy('id')->take(5)->get()->toArray(); ?>
Here User is model class.
Orderby id in descending order, limit to 5 records:
<?php DB::table('name')->orderBy('id', 'desc')->take(5)->get() ?>
or for pagination
<?php DB::table('name')->orderBy('id', 'desc')->paginate() ?>
If you want, you can try it:
<?php $result = User::orderBy('id', 'desc')->take(5)->get(); ?>