Reputation: 51
I want to query for some data that is of type Collection (according to Eloquent). When I query I want to set an upper bound. However, I cannot enforce this using
$data->skip(0)->take(5)->get();
nor by using
$data->offset(0)->limit(5)->get();
because $data
is already a Collection and no longer a Builder type. How can I get the same functionality for Collection type?
Upvotes: 5
Views: 7871
Reputation: 41820
You can get use the slice()
method to get a subset of the Collection.
$data->slice(0, 5);
Upvotes: 12