adrema/app/Invoice/Actions/HasValidation.php

51 lines
1.6 KiB
PHP
Raw Normal View History

2023-12-17 00:45:03 +01:00
<?php
namespace App\Invoice\Actions;
use App\Invoice\BillKind;
use App\Invoice\Enums\InvoiceStatus;
use Illuminate\Validation\Rule;
trait HasValidation
{
/**
* @return array<string, string|array<int, string|Rule>>
*/
public function rules(): array
{
return [
'status' => ['required', 'string', 'max:255', Rule::in(InvoiceStatus::values())],
'via' => ['required', 'string', 'max:255', Rule::in(BillKind::values())],
2023-12-17 23:00:52 +01:00
'usage' => 'required|max:255|string',
2023-12-18 01:15:16 +01:00
'mail_email' => 'nullable|string|max:255|email',
2023-12-17 00:45:03 +01:00
'to' => 'array',
'to.address' => 'required|string|max:255',
'to.location' => 'required|string|max:255',
'to.zip' => 'required|string|max:255',
'to.name' => 'required|string|max:255',
'greeting' => 'required|string|max:255',
'positions' => 'array',
'positions.*.description' => 'required|string|max:300',
'positions.*.price' => 'required|integer|min:0',
'positions.*.member_id' => 'required|exists:members,id',
'positions.*.id' => 'present|nullable|exists:invoice_positions,id',
];
}
/**
* @return array<string, string>
*/
public function getValidationAttributes(): array
{
return [
'to.address' => 'Adresse',
'to.name' => 'Name',
'to.zip' => 'PLZ',
'to.location' => 'Ort',
'status' => 'Status',
'via' => 'Rechnungsweg',
2023-12-17 23:00:52 +01:00
'usage' => 'Verwendungszweck',
2023-12-17 00:45:03 +01:00
];
}
}