1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* TransferRequest.php |
4
|
|
|
* Copyright (c) 2019 [email protected] |
5
|
|
|
* |
6
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii). |
7
|
|
|
* |
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
11
|
|
|
* License, or (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program 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 Affero General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
19
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace FireflyIII\Api\V1\Requests\Search; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
use FireflyIII\Api\V1\Requests\Request; |
26
|
|
|
use FireflyIII\Rules\IsTransferAccount; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Class TransferRequest |
30
|
|
|
*/ |
31
|
|
|
class TransferRequest extends Request |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* Authorize logged in users. |
35
|
|
|
* |
36
|
|
|
* @return bool |
37
|
|
|
*/ |
38
|
|
|
public function authorize(): bool |
39
|
|
|
{ |
40
|
|
|
// Only allow authenticated users |
41
|
|
|
return auth()->check(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return array |
46
|
|
|
*/ |
47
|
|
|
public function rules(): array |
48
|
|
|
{ |
49
|
|
|
return [ |
50
|
|
|
'source' => ['required', new IsTransferAccount], |
51
|
|
|
'destination' => ['required', new IsTransferAccount], |
52
|
|
|
'amount' => 'required|numeric|more:0', |
53
|
|
|
'description' => 'required|min:1', |
54
|
|
|
'date' => 'required|date', |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
} |