Question and answer is powered by AnsPress.io
If you want, you can try it:
<?php $result = User::orderBy('id', 'desc')->take(5)->get(); ?>
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() ?>
Follow this example code:
<?php User::orderBy('id')->take(5)->get()->toArray(); ?>
Here User is model class.