mardi 17 avril 2018

Laravel5: How to access paginated data before passing it to blade

I fetch some data with $merchants = Merchant::selectRaw($query)->with(...)-whereHas(...)->where(...)->paginate(10);

Now, I want to pluck() this data before passing it to blade. This doesn't work:

$collection = collect($merchants);

When I fetch the data with $merchants = Merchant::selectRaw($query)->with(...)-whereHas(...)->where(...)->get();, I can use $collection = collect($merchants); without any problemns, but pagination does not work for sure.

So, how can I combine paginate() with collect() or rahter access paginated data in the controller before passing it to blade?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire