vanilophp / product

Product Module for Vanilo (or any Laravel app)
https://vanilo.io
MIT License
18 stars 8 forks source link

How to paginate productFinder results? #7

Closed Romik90 closed 5 years ago

Romik90 commented 5 years ago

I couldn't find a way how to properly paginate productFinder results with standart laravel method

yusufkandemir commented 5 years ago

Firstly, I think I understand your problem but please be more expressive when describing problems.

I need to say that the ProductFinder is in scope of vanilophp/framework, so it would be better to open the issue there. And it is just a pretty wrapper for Laravel Query Builder. So this

$finder = new ProductFinder();
$results = $finder->havingPropertyValue($propertyValue)->withinTaxon($taxon)->getResults();

is same as this.

$results = Product::whereHas('propertyValues', function ($query) use ($propertyValue) {
            $query->where('id', $propertyValue->id);
        })->whereHas('taxons', function ($query) use ($taxon) {
            $query->where('id', $taxon->id);
        })->get();

So $results will be a Laravel Collection. As there is no method to paginate data or expose internal Query Builder, you can't paginate unfortunately. But I think we need to add such feature. I'll try to implement that and send a PR.