|
3 | 3 | namespace Torann\LaravelRepository\Contracts; |
4 | 4 |
|
5 | 5 | use Illuminate\Support\Collection; |
| 6 | +use Illuminate\Support\MessageBag; |
6 | 7 | use Illuminate\Database\Eloquent\Model; |
7 | 8 |
|
8 | 9 | /** |
@@ -168,24 +169,59 @@ public function delete(mixed $entity); |
168 | 169 | public function toSql(); |
169 | 170 |
|
170 | 171 | /** |
171 | | - * Add a message to the repository's error messages. |
172 | | - * |
| 172 | + * @return MessageBag |
| 173 | + */ |
| 174 | + public function getMessageBag(): MessageBag; |
| 175 | + |
| 176 | + /** |
173 | 177 | * @param string $message |
174 | 178 | * @param string $key |
175 | 179 | * |
176 | 180 | * @return static |
177 | 181 | */ |
178 | | - public function addError(string $message, string $key = 'message'); |
| 182 | + public function addMessage(string $message, string $key = 'message'): static; |
| 183 | + |
| 184 | + /** |
| 185 | + * @param string $key |
| 186 | + * |
| 187 | + * @return bool |
| 188 | + */ |
| 189 | + public function hasMessage(string $key = 'message'): bool; |
179 | 190 |
|
180 | 191 | /** |
181 | | - * Get the repository's error messages. |
| 192 | + * @param string|null $key |
| 193 | + * @param string|null $format |
| 194 | + * @param string $default |
| 195 | + * |
| 196 | + * @return string |
| 197 | + */ |
| 198 | + public function getMessage(string $key = null, string $format = null, string $default = ''): string; |
| 199 | + |
| 200 | + /** |
| 201 | + * Add an error to the message box |
| 202 | + * |
| 203 | + * @return bool |
| 204 | + */ |
| 205 | + public function addError(string $message); |
| 206 | + |
| 207 | + /** |
| 208 | + * Determine if any errors were reported |
| 209 | + * |
| 210 | + * @return bool |
| 211 | + */ |
| 212 | + public function hasErrors(): bool; |
| 213 | + |
| 214 | + /** |
| 215 | + * Get all error messages. |
| 216 | + * |
| 217 | + * @param string|null $format |
182 | 218 | * |
183 | | - * @return \Illuminate\Support\MessageBag |
| 219 | + * @return array |
184 | 220 | */ |
185 | | - public function getErrors(); |
| 221 | + public function getErrors(): array; |
186 | 222 |
|
187 | 223 | /** |
188 | | - * Get the repository's first error message. |
| 224 | + * Get a single error message. |
189 | 225 | * |
190 | 226 | * @param string $default |
191 | 227 | * |
|
0 commit comments