@@ -20,6 +20,7 @@ public function ratings()
2020 *
2121 * @param $round
2222 * @param $onlyApproved
23+ *
2324 * @return mixed
2425 */
2526 public function averageRating ($ round = null , $ onlyApproved = false )
@@ -43,6 +44,7 @@ public function averageRating($round= null, $onlyApproved= false)
4344 *
4445 * @var $round
4546 * @var $onlyApproved
47+ *
4648 * @return mixed
4749 */
4850 public function averageCustomerServiceRating ($ round = null , $ onlyApproved = false )
@@ -66,6 +68,7 @@ public function averageCustomerServiceRating($round= null, $onlyApproved= false)
6668 *
6769 * @param $round
6870 * @param $onlyApproved
71+ *
6972 * @return mixed
7073 */
7174 public function averageQualityRating ($ round = null , $ onlyApproved = false )
@@ -89,6 +92,7 @@ public function averageQualityRating($round = null, $onlyApproved= false)
8992 *
9093 * @var $round
9194 * @var $onlyApproved
95+ *
9296 * @return mixed
9397 */
9498 public function averageFriendlyRating ($ round = null , $ onlyApproved = false )
@@ -112,9 +116,10 @@ public function averageFriendlyRating($round = null, $onlyApproved= false)
112116 *
113117 * @var $round
114118 * @var $onlyApproved
119+ *
115120 * @return mixed
116121 */
117- public function averagePricingRating ($ round = null , $ onlyApproved = false )
122+ public function averagePricingRating ($ round = null , $ onlyApproved = false )
118123 {
119124 $ where = $ onlyApproved ? [['approved ' , '1 ' ]] : [];
120125
@@ -133,9 +138,10 @@ public function averagePricingRating($round = null, $onlyApproved= false)
133138
134139 /**
135140 * @var $onlyApproved
141+ *
136142 * @return mixed
137143 */
138- public function countRating ($ onlyApproved = false )
144+ public function countRating ($ onlyApproved = false )
139145 {
140146 return $ this ->ratings ()
141147 ->selectRaw ('count(rating) as countReviewRateable ' )
@@ -145,9 +151,10 @@ public function countRating($onlyApproved= false)
145151
146152 /**
147153 * @var $onlyApproved
154+ *
148155 * @return mixed
149156 */
150- public function countCustomerServiceRating ($ onlyApproved = false )
157+ public function countCustomerServiceRating ($ onlyApproved = false )
151158 {
152159 return $ this ->ratings ()
153160 ->selectRaw ('count(customer_service_rating) as countCustomerServiceReviewRateable ' )
@@ -157,9 +164,10 @@ public function countCustomerServiceRating($onlyApproved= false)
157164
158165 /**
159166 * @var $onlyApproved
167+ *
160168 * @return mixed
161169 */
162- public function countQualityRating ($ onlyApproved = false )
170+ public function countQualityRating ($ onlyApproved = false )
163171 {
164172 return $ this ->ratings ()
165173 ->selectRaw ('count(quality_rating) as countQualityReviewRateable ' )
@@ -169,9 +177,10 @@ public function countQualityRating($onlyApproved= false)
169177
170178 /**
171179 * @var $onlyApproved
180+ *
172181 * @return mixed
173182 */
174- public function countFriendlyRating ($ onlyApproved = false ) {
183+ public function countFriendlyRating ($ onlyApproved = false ) {
175184 return $ this ->ratings ()
176185 ->selectRaw ('count(friendly_rating) as countFriendlyReviewRateable ' )
177186 ->where ($ onlyApproved ? [['approved ' , '1 ' ]] : [])
@@ -180,9 +189,10 @@ public function countFriendlyRating($onlyApproved= false) {
180189
181190 /**
182191 * @var $onlyApproved
192+ *
183193 * @return mixed
184194 */
185- public function countPriceRating ($ onlyApproved = false ) {
195+ public function countPriceRating ($ onlyApproved = false ) {
186196 return $ this ->ratings ()
187197 ->selectRaw ('count(price_rating) as countPriceReviewRateable ' )
188198 ->where ($ onlyApproved ? [['approved ' , '1 ' ]] : [])
@@ -191,9 +201,10 @@ public function countPriceRating($onlyApproved= false) {
191201
192202 /**
193203 * @var $onlyApproved
204+ *
194205 * @return mixed
195206 */
196- public function sumRating ($ onlyApproved = false )
207+ public function sumRating ($ onlyApproved = false )
197208 {
198209 return $ this ->ratings ()
199210 ->selectRaw ('SUM(rating) as sumReviewRateable ' )
@@ -242,6 +253,7 @@ public function updateRating($id, $data, Model $parent = null)
242253 *
243254 * @param $id
244255 * @param $sort
256+ *
245257 * @return mixed
246258 */
247259 public function getAllRatings ($ id , $ sort = 'desc ' )
@@ -253,6 +265,7 @@ public function getAllRatings($id, $sort = 'desc')
253265 *
254266 * @param $id
255267 * @param $sort
268+ *
256269 * @return mixed
257270 */
258271 public function getApprovedRatings ($ id , $ sort = 'desc ' )
@@ -264,6 +277,7 @@ public function getApprovedRatings($id, $sort = 'desc')
264277 *
265278 * @param $id
266279 * @param $sort
280+ *
267281 * @return mixed
268282 */
269283 public function getNotApprovedRatings ($ id , $ sort = 'desc ' )
@@ -275,6 +289,7 @@ public function getNotApprovedRatings($id, $sort = 'desc')
275289 * @param $id
276290 * @param $limit
277291 * @param $sort
292+ *
278293 * @return mixed
279294 */
280295 public function getRecentRatings ($ id , $ limit = 5 , $ sort = 'desc ' )
@@ -287,13 +302,27 @@ public function getRecentRatings($id, $limit = 5, $sort = 'desc')
287302 * @param $limit
288303 * @param $approved
289304 * @param $sort
305+ *
290306 * @return mixed
291307 */
292308 public function getRecentUserRatings ($ id , $ limit = 5 , $ approved = true , $ sort = 'desc ' )
293309 {
294310 return (new Rating ())->getRecentUserRatings ($ id , $ limit , $ approved , $ sort );
295311 }
296312
313+ /**
314+ * @param $rating
315+ * @param $type
316+ * @param $approved
317+ * @param $sort
318+ *
319+ * @return mixed
320+ */
321+ public function getCollectionByAverageRating ($ rating , $ type = 'rating ' , $ approved = true , $ sort = 'desc ' )
322+ {
323+ return (new Rating ())->getCollectionByAverageRating ($ rating , $ approved , $ sort );
324+ }
325+
297326 /**
298327 * @param $id
299328 *
0 commit comments