Limit Eloquent Result Using Using take() and limit()
For example, let's say you want to limit the querying number of "posts" and to do that you can write your code like the following.
<?php use App\Models\Post; // using take() Post::query()->take(20)->get(); // using limit() Post::query()->limit(20)->get();
Limit Eloquent Result Using Pagination
Sometimes you might also want to use the pagination approach and to do that you can write your code like below.
<?php use App\Models\Post; $posts = Post::query()->paginate(20);
Leave a reply