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

25 lines
589 B
PHP
Raw Normal View History

2024-08-30 06:16:16 +02:00
<?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([
2024-08-30 09:40:57 +02:00
'ids' => $ids,
2024-08-30 06:16:16 +02:00
], [
'ids' => 'required|array|min:1',
2024-08-30 09:40:57 +02:00
'ids.*' => 'required|uuid|distinct',
2024-08-30 06:16:16 +02:00
]);
if ($validator->fails()) {
throw new HttpResponseException(response()->json($validator->errors(), 422));
}
2024-08-30 09:40:57 +02:00
2024-08-30 06:16:16 +02:00
return $ids;
}
}