Closed
Description
To optimise the validation of list of values through the DB table, we need to implement custom validation rule.
How it should works:
public function rules(): array
{
return [
//will make `whereIn` query to determine which of values are not exists in DB
'ids' => 'array|list_exists:users,id',
'ids.*' => 'integer',
//will works the same as in previous example but will find record in the `clients` table in `user_id` field and pluck `id` field from the input collection
'users' => 'array|list_exists:clients,user_id,id',
'users.id' => 'integer'
];
}