Skip to content

Commit a752acb

Browse files
committed
Wip
1 parent 3224626 commit a752acb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Traits/ReviewRateable.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,19 @@ public function totalReviews(bool $approved = true): int
332332
return $this->reviews()->where('approved', $approved)->count();
333333
}
334334

335+
/**
336+
* Get the total number of reviews for the model.
337+
*
338+
* @param bool $approved
339+
* @return int
340+
*/
341+
public function totalDepartmentReviews(string $department, bool $approved = true): int
342+
{
343+
return $this->reviews()
344+
->where('department', $department)
345+
->where('approved', $approved)->count();
346+
}
347+
335348
/**
336349
* Calculate the overall average rating for all ratings across all reviews,
337350
* optionally filtering by the approved status.

0 commit comments

Comments
 (0)