42 lines
1,022 B
PHP
42 lines
1,022 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Bo;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Infrastructure\Adapters\Services\AppAdminAuthService;
|
|
|
|
class MassActionRequest extends FormRequest
|
|
{
|
|
public function __construct(
|
|
private readonly AppAdminAuthService $authService
|
|
) {
|
|
}
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return $this->authService->check();
|
|
}
|
|
|
|
#[\Override]
|
|
protected function prepareForValidation()
|
|
{
|
|
$this->merge([
|
|
'models' => $this->array('models'),
|
|
'publish' => $this->boolean('publish'),
|
|
'unpublish' => $this->boolean('unpublish'),
|
|
]);
|
|
}
|
|
|
|
/** @return array<string,mixed>*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'models' => ['required', 'array'],
|
|
'models.*' => ['string', 'min:1'],
|
|
'publish' => ['required', 'boolean'],
|
|
'unpublish' => ['required', 'boolean'],
|
|
];
|
|
}
|
|
}
|