|
7 | 7 | interface ReviewRateable |
8 | 8 | { |
9 | 9 | /** |
| 10 | + * Get all reviews for the model. |
| 11 | + * |
10 | 12 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
11 | 13 | */ |
12 | | - public function ratings(); |
| 14 | + public function reviews(); |
13 | 15 |
|
14 | 16 | /** |
| 17 | + * Get the rating types for the model. |
15 | 18 | * |
16 | | - * @param $round |
17 | | - * @return double |
| 19 | + * @return array |
18 | 20 | */ |
19 | | - public function averageRating($round = null); |
| 21 | + public function ratingTypes(); |
20 | 22 |
|
21 | 23 | /** |
| 24 | + * Add a review to the model. |
22 | 25 | * |
23 | | - * @param $round |
24 | | - * @return double |
| 26 | + * @param array $data |
| 27 | + * @return \Illuminate\Database\Eloquent\Model |
25 | 28 | */ |
26 | | - public function averageCustomerServiceRating($round = null); |
| 29 | + public function addReview(array $data); |
27 | 30 |
|
28 | 31 | /** |
| 32 | + * Add a rating to a specific review. |
29 | 33 | * |
30 | | - * @param $round |
31 | | - * @return double |
| 34 | + * @param int $reviewId |
| 35 | + * @param string $type |
| 36 | + * @param int $rating |
| 37 | + * @return void |
32 | 38 | */ |
33 | | - public function averageQualityRating($round = null); |
| 39 | + public function addRatingToReview($reviewId, $type, $rating); |
34 | 40 |
|
35 | 41 | /** |
| 42 | + * Get a specific rating from a review. |
36 | 43 | * |
37 | | - * @param $round |
38 | | - * @return double |
| 44 | + * @param int $reviewId |
| 45 | + * @param string $type |
| 46 | + * @return int|null |
39 | 47 | */ |
40 | | - public function averageFriendlyRating($round = null); |
| 48 | + public function getReviewRating($reviewId, $type); |
41 | 49 |
|
42 | 50 | /** |
| 51 | + * Calculate the average rating for a specific type. |
43 | 52 | * |
44 | | - * @param $round |
| 53 | + * @param string|null $type |
| 54 | + * @param int|null $round |
45 | 55 | * @return double |
46 | 56 | */ |
47 | | - public function averagePricingRating($round = null); |
48 | | - |
49 | | - /** |
50 | | - * |
51 | | - * @return int |
52 | | - */ |
53 | | - public function countRating(); |
54 | | - |
55 | | - /** |
56 | | - * |
57 | | - * @return int |
58 | | - */ |
59 | | - public function countCustomerServiceRating(); |
60 | | - |
61 | | - /** |
62 | | - * |
63 | | - * @return int |
64 | | - */ |
65 | | - public function countQualityRating(); |
66 | | - |
67 | | - /** |
68 | | - * |
69 | | - * @return int |
70 | | - */ |
71 | | - public function countFriendlyRating(); |
| 57 | + public function averageRating($type = 'rating', $round = null); |
72 | 58 |
|
73 | 59 | /** |
| 60 | + * Count the number of ratings for a specific type. |
74 | 61 | * |
| 62 | + * @param string|null $type |
75 | 63 | * @return int |
76 | 64 | */ |
77 | | - public function countPriceRating(); |
| 65 | + public function countRating($type = 'rating'); |
78 | 66 |
|
79 | 67 | /** |
| 68 | + * Sum the ratings for a specific type. |
80 | 69 | * |
| 70 | + * @param string|null $type |
81 | 71 | * @return double |
82 | 72 | */ |
83 | | - public function sumRating(); |
| 73 | + public function sumRating($type = 'rating'); |
84 | 74 |
|
85 | 75 | /** |
| 76 | + * Calculate the rating percentage for a specific type. |
86 | 77 | * |
87 | | - * @param $max |
88 | | - * |
| 78 | + * @param string|null $type |
| 79 | + * @param int $max |
89 | 80 | * @return double |
90 | 81 | */ |
91 | | - public function ratingPercent($max = 5); |
| 82 | + public function ratingPercent($type = 'rating', $max = 5); |
92 | 83 |
|
93 | 84 | /** |
| 85 | + * Retrieve all ratings for the given ID. |
94 | 86 | * |
95 | | - * @param $data |
96 | | - * @param $author |
97 | | - * @param $parent |
98 | | - * |
99 | | - * @return static |
100 | | - */ |
101 | | - public function rating($data, Model $author, Model $parent = null); |
102 | | - |
103 | | - /** |
104 | | - * |
105 | | - * @param $id |
106 | | - * @param $data |
107 | | - * @param $parent |
108 | | - * |
109 | | - * @return mixed |
110 | | - */ |
111 | | - public function updateRating($id, $data, Model $parent = null); |
112 | | - |
113 | | - /** |
114 | | - * |
115 | | - * @param $id |
116 | | - * @param $sort |
117 | | - * |
| 87 | + * @param int $id |
| 88 | + * @param string $sort |
118 | 89 | * @return mixed |
119 | 90 | */ |
120 | 91 | public function getAllRatings($id, $sort = 'desc'); |
121 | 92 |
|
122 | 93 | /** |
| 94 | + * Retrieve all approved ratings for the given ID. |
123 | 95 | * |
124 | | - * @param $id |
125 | | - * @param $sort |
126 | | - * |
| 96 | + * @param int $id |
| 97 | + * @param string $sort |
127 | 98 | * @return mixed |
128 | 99 | */ |
129 | 100 | public function getApprovedRatings($id, $sort = 'desc'); |
130 | 101 |
|
131 | 102 | /** |
| 103 | + * Retrieve all non-approved ratings for the given ID. |
132 | 104 | * |
133 | | - * @param $id |
134 | | - * @param $sort |
135 | | - * |
| 105 | + * @param int $id |
| 106 | + * @param string $sort |
136 | 107 | * @return mixed |
137 | 108 | */ |
138 | 109 | public function getNotApprovedRatings($id, $sort = 'desc'); |
139 | 110 |
|
140 | 111 | /** |
141 | | - * @param $id |
142 | | - * @param $limit |
143 | | - * @param $sort |
| 112 | + * Retrieve recent ratings for the given ID. |
144 | 113 | * |
| 114 | + * @param int $id |
| 115 | + * @param int $limit |
| 116 | + * @param string $sort |
145 | 117 | * @return mixed |
146 | 118 | */ |
147 | 119 | public function getRecentRatings($id, $limit = 5, $sort = 'desc'); |
148 | 120 |
|
149 | 121 | /** |
150 | | - * @param $id |
151 | | - * @param $limit |
152 | | - * @param $approved |
153 | | - * @param $sort |
| 122 | + * Retrieve recent user ratings. |
154 | 123 | * |
| 124 | + * @param int $id |
| 125 | + * @param int $limit |
| 126 | + * @param bool $approved |
| 127 | + * @param string $sort |
155 | 128 | * @return mixed |
156 | 129 | */ |
157 | 130 | public function getRecentUserRatings($id, $limit = 5, $approved = true, $sort = 'desc'); |
158 | 131 |
|
159 | 132 | /** |
160 | | - * @param $rating |
161 | | - * @para $type |
162 | | - * @param $approved |
163 | | - * @param $sort |
| 133 | + * Get a collection of reviews by average rating. |
164 | 134 | * |
| 135 | + * @param double $rating |
| 136 | + * @param string $type |
| 137 | + * @param bool $approved |
| 138 | + * @param string $sort |
165 | 139 | * @return mixed |
166 | 140 | */ |
167 | 141 | public function getCollectionByAverageRating($rating, $type = 'rating', $approved = true, $sort = 'desc'); |
168 | 142 |
|
169 | 143 | /** |
| 144 | + * Delete a rating by its ID. |
170 | 145 | * |
171 | | - * @param $id |
172 | | - * |
| 146 | + * @param int $id |
173 | 147 | * @return mixed |
174 | 148 | */ |
175 | 149 | public function deleteRating($id); |
176 | 150 |
|
177 | 151 | /** |
| 152 | + * Retrieve user ratings. |
178 | 153 | * |
179 | | - * @param $id |
| 154 | + * @param int $id |
| 155 | + * @param string $author |
| 156 | + * @param string $sort |
180 | 157 | * @return mixed |
181 | 158 | */ |
182 | 159 | public function getUserRatings($id, $author, $sort = 'desc'); |
183 | 160 | } |
| 161 | + |
0 commit comments