panthro
panthro

Reputation: 24059

Return collection of model from paginate?

When I do

User::select('id')->get()

It returns a collection.

When I do:

User::select('id')->paginate(10)->items()

It returns an array.

Is there any method that returns the underlying collection of the model and not an array?

Note, I'm aware of collect(User::select('id')->paginate(10)->items()).

Upvotes: 0

Views: 31

Answers (1)

OMR
OMR

Reputation: 12208

you can use the method getCollection witch is earned from AbstractPaginator

$userscollection=User::select('id')->paginate(10)->getCollection();

now $userscollection will be the underling collection you want.

Upvotes: 1

Related Questions