41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Tenant;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
class EventAddonRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'extra_photos' => ['nullable', 'integer', 'min:1'],
|
|
'extra_guests' => ['nullable', 'integer', 'min:1'],
|
|
'extend_gallery_days' => ['nullable', 'integer', 'min:1'],
|
|
'reason' => ['nullable', 'string', 'max:255'],
|
|
];
|
|
}
|
|
|
|
protected function passedValidation(): void
|
|
{
|
|
if (
|
|
$this->input('extra_photos') === null
|
|
&& $this->input('extra_guests') === null
|
|
&& $this->input('extend_gallery_days') === null
|
|
) {
|
|
throw ValidationException::withMessages([
|
|
'addons' => __('Please provide at least one add-on to apply.'),
|
|
]);
|
|
}
|
|
}
|
|
}
|