Skip to content

Commit 8daf664

Browse files
authored
Update RepositoryContract.php
1 parent 77c3afb commit 8daf664

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

src/Contracts/RepositoryContract.php

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Torann\LaravelRepository\Contracts;
44

55
use Illuminate\Support\Collection;
6+
use Illuminate\Support\MessageBag;
67
use Illuminate\Database\Eloquent\Model;
78

89
/**
@@ -168,24 +169,59 @@ public function delete(mixed $entity);
168169
public function toSql();
169170

170171
/**
171-
* Add a message to the repository's error messages.
172-
*
172+
* @return MessageBag
173+
*/
174+
public function getMessageBag(): MessageBag;
175+
176+
/**
173177
* @param string $message
174178
* @param string $key
175179
*
176180
* @return static
177181
*/
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;
179190

180191
/**
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
182218
*
183-
* @return \Illuminate\Support\MessageBag
219+
* @return array
184220
*/
185-
public function getErrors();
221+
public function getErrors(): array;
186222

187223
/**
188-
* Get the repository's first error message.
224+
* Get a single error message.
189225
*
190226
* @param string $default
191227
*

0 commit comments

Comments
 (0)