Laravel Eloquent limit() Query Example

Laravel 6 , Laravel , Laravel 7

Nicesnippets

116910

15-07-2020


Laravel Eloquent limit() Query Example

Hello Friend,

In this blog, I would like share with you nformation about Offset and Limit query in laravel application. We will learn laravel limit query builder.

The limit is used to get limit data. To limit the number of results returned from the query.

In this example, I will show you get only 10 records to users table. Then use the offset and limit query in laravel for it. So let’s understand through the query.

Example 1


/**

* The attributes that are mass assignable.

*

* @var array

*/

public function index()

{

$users = DB::table('users')->limit(10)->get();

}

Example 2

/**

* The attributes that are mass assignable.

*

* @var array

*/

public function index()

{

$users = User::limit(5)->get();

}

It will help you...


Recommended Posts