39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Api\V1;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
final class BulkApproveShiftAssignmentRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/** @return array<string, mixed> */
|
|
public function rules(): array
|
|
{
|
|
$event = $this->route('event');
|
|
|
|
return [
|
|
'assignment_ids' => ['required', 'array', 'min:1', 'max:100'],
|
|
'assignment_ids.*' => [
|
|
'required', 'ulid',
|
|
Rule::exists('shift_assignments', 'id')->where(function ($query) use ($event) {
|
|
$query->whereIn('shift_id', function ($q) use ($event) {
|
|
$q->select('id')->from('shifts')
|
|
->whereIn('festival_section_id', function ($q2) use ($event) {
|
|
$q2->select('id')->from('festival_sections')
|
|
->where('event_id', $event->id);
|
|
});
|
|
});
|
|
}),
|
|
],
|
|
];
|
|
}
|
|
}
|