first commit
Some checks failed
tests / ci (push) Has been cancelled

This commit is contained in:
2026-10-27 11:01:11 +00:00
parent 9b8b21c853
commit fb04d71a8d
29 changed files with 9733 additions and 326 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreRecurringReservationRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()?->active === true;
}
/** @return array<string, list<string>> */
public function rules(): array
{
return [
'purpose' => ['required', 'string', 'min:10', 'max:2000'],
'usage_location' => ['required', 'string', 'max:255'],
'terms_accepted' => ['accepted'],
'occurrences' => ['required', 'array', 'min:1', 'max:26'],
'occurrences.*.starts_at' => ['required', 'date', 'after:now'],
'occurrences.*.ends_at' => ['required', 'date', 'after:occurrences.*.starts_at'],
'occurrences.*.asset_ids' => ['required', 'array', 'min:1'],
'occurrences.*.asset_ids.*' => ['required', 'integer', 'exists:snipe_assets,id'],
];
}
}

View File

@@ -34,6 +34,13 @@ class StoreReservationRequest extends FormRequest
public function after(): array
{
return [function (Validator $validator): void {
$now = now();
$nowFormatted = $now->format('d/m/Y \à\s H:i');
if ($validator->errors()->has('starts_at')) {
$validator->errors()->add('starts_at', "A data de início deve ser posterior às {$nowFormatted}.");
}
if ($validator->errors()->hasAny(['starts_at', 'ends_at'])) {
return;
}