@@ 8-28 (lines=21) @@ | ||
5 | use Spatie\ValidationRules\IsDateRule; |
|
6 | use Illuminate\Contracts\Validation\Rule; |
|
7 | ||
8 | class FutureDate implements Rule |
|
9 | { |
|
10 | use IsDateRule; |
|
11 | ||
12 | public function __construct(string $format = 'Y-m-d') |
|
13 | { |
|
14 | $this->format = $format; |
|
15 | } |
|
16 | ||
17 | public function passes($attribute, $value): bool |
|
18 | { |
|
19 | $date = $this->createDate($value); |
|
20 | ||
21 | return $date->isFuture(); |
|
22 | } |
|
23 | ||
24 | public function message(): string |
|
25 | { |
|
26 | return __('validationRules.future_date'); |
|
27 | } |
|
28 | } |
|
29 |
@@ 8-28 (lines=21) @@ | ||
5 | use Spatie\ValidationRules\IsDateRule; |
|
6 | use Illuminate\Contracts\Validation\Rule; |
|
7 | ||
8 | class PastDate implements Rule |
|
9 | { |
|
10 | use IsDateRule; |
|
11 | ||
12 | public function __construct(string $format = 'Y-m-d') |
|
13 | { |
|
14 | $this->format = $format; |
|
15 | } |
|
16 | ||
17 | public function passes($attribute, $value): bool |
|
18 | { |
|
19 | $date = $this->createDate($value); |
|
20 | ||
21 | return $date->isPast(); |
|
22 | } |
|
23 | ||
24 | public function message(): string |
|
25 | { |
|
26 | return __('validationRules.past_date'); |
|
27 | } |
|
28 | } |
|
29 |