megahunt.test/app/Http/Requests/TrashGroupRequest.php

25 lines
589 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Http\Exceptions\HttpResponseException;
class TrashGroupRequest extends AuthorizedRequest
{
public function getValidatedIds(): array
{
$ids = explode(',', $this->query('ids'));
$validator = validator([
'ids' => $ids,
], [
'ids' => 'required|array|min:1',
'ids.*' => 'required|uuid|distinct',
]);
if ($validator->fails()) {
throw new HttpResponseException(response()->json($validator->errors(), 422));
}
return $ids;
}
}