Hey Guys,
I was wondering if there is a way to handle pagination.
I would like to use this library to create something like the WordPress media library, but I do not want to possibly retrieve hundreds of files at once.
Any plans to include something for this? Or is there a easy way to achieve pagination?
Thanks in advance!
Can't you use the media() relation for that?
Yes I can, but that removes the easy use of collection and such I believe.
It's Eloquent, if you know how Eloquent works you can do pretty much everything you want.
$media = Collection::find(1)->media()->where('collection_name', 'default')->paginate();
You write a little more, yes, but it's way more flexible than using the getMedia() method.
It would be nice if we had a few query scopes defined on the Media model, so we could use stuff like ->onCollection(:collection-name-here).
But it is what it is.
That's an excellent answer @brunogaspar. :+1:
Most helpful comment
It's Eloquent, if you know how Eloquent works you can do pretty much everything you want.
You write a little more, yes, but it's way more flexible than using the
getMedia()method.It would be nice if we had a few query scopes defined on the Media model, so we could use stuff like
->onCollection(:collection-name-here).But it is what it is.