|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Squareetlabs\VeriFactu\Http\Requests; |
|
6
|
|
|
|
|
7
|
|
|
use Illuminate\Foundation\Http\FormRequest; |
|
8
|
|
|
use Illuminate\Validation\Rule; |
|
9
|
|
|
use Squareetlabs\VeriFactu\Enums\InvoiceType; |
|
10
|
|
|
|
|
11
|
|
|
class StoreInvoiceRequest extends FormRequest |
|
12
|
|
|
{ |
|
13
|
|
|
public function authorize(): bool |
|
14
|
|
|
{ |
|
15
|
|
|
return true; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function rules(): array |
|
19
|
|
|
{ |
|
20
|
|
|
return [ |
|
21
|
|
|
'number' => ['required', 'string', 'max:60', 'unique:invoices,number'], |
|
22
|
|
|
'date' => ['required', 'date'], |
|
23
|
|
|
'customer_name' => ['required', 'string', 'max:120'], |
|
24
|
|
|
'customer_tax_id' => ['required', 'string', 'max:20'], |
|
25
|
|
|
'customer_country' => ['nullable', 'string', 'size:2'], |
|
26
|
|
|
'issuer_name' => ['required', 'string', 'max:120'], |
|
27
|
|
|
'issuer_tax_id' => ['required', 'string', 'max:20'], |
|
28
|
|
|
'issuer_country' => ['nullable', 'string', 'size:2'], |
|
29
|
|
|
'amount' => ['required', 'numeric', 'min:0'], |
|
30
|
|
|
'tax' => ['required', 'numeric', 'min:0'], |
|
31
|
|
|
'total' => ['required', 'numeric', 'min:0'], |
|
32
|
|
|
'type' => ['required', Rule::in(array_column(InvoiceType::cases(), 'value'))], |
|
33
|
|
|
'external_reference' => ['nullable', 'string', 'max:60'], |
|
34
|
|
|
'description' => ['nullable', 'string', 'max:500'], |
|
35
|
|
|
'status' => ['nullable', 'string', 'max:30'], |
|
36
|
|
|
'issued_at' => ['nullable', 'date'], |
|
37
|
|
|
'cancelled_at' => ['nullable', 'date'], |
|
38
|
|
|
]; |
|
39
|
|
|
} |
|
40
|
|
|
} |