Support the ongoing development of Laravel.io →
posted 11 years ago
Eloquent

Hi guys i'm trying to Load all Collection with Items inside Collection with Eager Load but i only want 5 items , how do i do that?

Currently i'm doing $collectionList = Collection::where('user_id','=',$user_details->id)->get();

To get a list of Collection. I'm looking if i can use Limit or Select only a fix amount of items while displaying the Main Collection. The aim is to display the Collection with some example of the items inside this collection. Therefore it wont make sense if i load all 500 items and only use 6.

Thanks in advance! Any advice is appreciated

Last updated 3 years ago.
0

I think you are talking about pagination.

like,

$collectionList = Collection::where('user_id','=',$user_details->id)->paginate(5);

See more at http://laravel.com/docs/pagination

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.