PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.1
1.7.1 1.7.0 1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 All 51 releases
← All changes | app/Models/ProductReview.php +15 -0 1.7.0 → 1.7.1 View file →
@@ -165,10 +165,25 @@
165 165 {
166 166 return $postId ? $query->where('post_id', (int) $postId) : $query;
167 167 }
168 168
169 + /**
170 + * Reviews with exactly this star rating, or any of a list of them (the
171 + * storefront's star chips can be combined).
172 + *
173 + * @param \FluentCart\Framework\Database\Orm\Builder $query
174 + * @param int|int[]|null $rating
175 + */
169 176 public function scopeOfRating($query, $rating)
170 177 {
178 + if (is_array($rating)) {
179 + $ratings = array_values(array_filter(array_map('intval', array_slice($rating, 0, 5)), function ($value) {
180 + return $value >= 1 && $value <= 5;
181 + }));
182 +
183 + return $ratings ? $query->whereIn('rating', $ratings) : $query;
184 + }
185 +
171 186 if (!$rating || !is_numeric($rating)) {
172 187 return $query;
173 188 }
174 189 return $query->where('rating', (int) $rating);