2026-06-23 10:10:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Modules\History\Requests;
|
|
|
|
|
|
2026-07-18 09:34:18 +00:00
|
|
|
use App\Modules\History\Models\HistoryEntry;
|
|
|
|
|
use Illuminate\Contracts\Validation\Validator;
|
2026-06-23 10:10:28 +00:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
|
|
class UpdateHistoryEntryRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
public function authorize(): bool { return true; }
|
|
|
|
|
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'body' => ['required', 'string', 'max:65535'],
|
2026-07-18 09:34:18 +00:00
|
|
|
'occurred_at' => ['nullable', 'date_format:Y-m-d\TH:i:s'],
|
2026-06-23 10:10:28 +00:00
|
|
|
];
|
|
|
|
|
}
|
2026-07-18 09:34:18 +00:00
|
|
|
|
|
|
|
|
public function withValidator(Validator $validator): void
|
|
|
|
|
{
|
|
|
|
|
$validator->after(function (Validator $validator) {
|
|
|
|
|
$entry = $this->route('historyEntry');
|
|
|
|
|
|
|
|
|
|
if ($entry instanceof HistoryEntry
|
|
|
|
|
&& $entry->entryType?->requires_datetime
|
|
|
|
|
&& ! $this->filled('occurred_at')
|
|
|
|
|
) {
|
|
|
|
|
$validator->errors()->add(
|
|
|
|
|
'occurred_at',
|
|
|
|
|
'Für diesen Verlaufstyp sind Datum und Uhrzeit erforderlich.'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-06-23 10:10:28 +00:00
|
|
|
}
|