1 | <?php |
||
2 | /** |
||
3 | * RecurrenceStoreRequest.php |
||
4 | * Copyright (c) 2019 [email protected] |
||
5 | * |
||
6 | * This file is part of Firefly III. |
||
7 | * |
||
8 | * Firefly III is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU General Public License as published by |
||
10 | * the Free Software Foundation, either version 3 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * Firefly III is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU General Public License |
||
19 | * along with Firefly III. If not, see <http://www.gnu.org/licenses/>. |
||
20 | */ |
||
21 | |||
22 | declare(strict_types=1); |
||
23 | |||
24 | namespace FireflyIII\Api\V1\Requests; |
||
25 | |||
26 | use FireflyIII\Validation\RecurrenceValidation; |
||
27 | use FireflyIII\Validation\TransactionValidation; |
||
28 | use Illuminate\Validation\Validator; |
||
29 | |||
30 | /** |
||
31 | * Class RecurrenceStoreRequest |
||
32 | */ |
||
33 | class RecurrenceStoreRequest extends Request |
||
34 | { |
||
35 | use RecurrenceValidation, TransactionValidation; |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
36 | |||
37 | /** |
||
38 | * Authorize logged in users. |
||
39 | * |
||
40 | * @return bool |
||
41 | */ |
||
42 | public function authorize(): bool |
||
43 | { |
||
44 | // Only allow authenticated users |
||
45 | return auth()->check(); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * The rules that the incoming request must be matched against. |
||
50 | * |
||
51 | * @return array |
||
52 | */ |
||
53 | public function rules(): array |
||
54 | { |
||
55 | return $this->rulesRecurrence(); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Configure the validator instance. |
||
60 | * |
||
61 | * @param Validator $validator |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | public function withValidator(Validator $validator): void |
||
66 | { |
||
67 | $validator->after( |
||
68 | function (Validator $validator) { |
||
69 | $this->validateOneRecurrenceTransaction($validator); |
||
70 | $this->validateOneRepetition($validator); |
||
71 | $this->validateRecurrenceRepetition($validator); |
||
72 | $this->validateRepetitionMoment($validator); |
||
73 | $this->validateForeignCurrencyInformation($validator); |
||
74 | $this->validateAccountInformation($validator); |
||
75 | } |
||
76 | ); |
||
77 | } |
||
78 | } |
||
79 |