Files
crewli/api/app/Http/Requests/Api/V1/BulkConfirmIdentityMatchesRequest.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 BulkConfirmIdentityMatchesRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/** @return array<string, mixed> */
public function rules(): array
{
$organisation = $this->route('organisation');
return [
'match_ids' => ['required', 'array', 'min:1', 'max:100'],
'match_ids.*' => [
'required', 'string',
Rule::exists('person_identity_matches', 'id')->where(function ($query) use ($organisation) {
$query->whereIn('person_id', function ($q) use ($organisation) {
$q->select('id')->from('persons')
->whereIn('event_id', function ($q2) use ($organisation) {
$q2->select('id')->from('events')
->where('organisation_id', $organisation->id);
});
});
}),
],
];
}
}