29 lines
958 B
PHP
29 lines
958 B
PHP
<?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'],
|
|
];
|
|
}
|
|
}
|