In my Controller
$items = Item::all();
I want to get the first 6 items only
How to change the code?
In my Controller
$items = Item::all();
I want to get the first 6 items only
How to change the code?
Use take function
$items = Item::take(6)->get();
Check in laravel docs : https://laravel.com/docs/5.2/queries
To limit the number of results returned from the query you may use the take() method.
$items = Item::take(6)->get();