28 lines
830 B
PHP
28 lines
830 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreReservationRequest 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'],
|
|
'starts_at' => ['required', 'date', 'after:now'],
|
|
'ends_at' => ['required', 'date', 'after:starts_at'],
|
|
'asset_ids' => ['required', 'array', 'min:1', 'max:10'],
|
|
'asset_ids.*' => ['required', 'integer', 'distinct', 'exists:snipe_assets,id'],
|
|
'terms_accepted' => ['accepted'],
|
|
];
|
|
}
|
|
}
|