Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
42 lines
1,009 B
PHP
42 lines
1,009 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Bo;
|
|
|
|
use App\Cqs\Actions\Common\ChangeModelOrderPositionInput;
|
|
use App\Interfaces\ModelWithOrder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Infrastructure\Adapters\Services\AppAdminAuthService;
|
|
|
|
class ChangeSelectedOrderRequest extends FormRequest
|
|
{
|
|
public function __construct(
|
|
private readonly AppAdminAuthService $authService
|
|
) {
|
|
}
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return $this->authService->check();
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'order' => ['required', 'integer', 'min:1'],
|
|
];
|
|
}
|
|
|
|
public function toChangeModelOrderPositionInput(Model & ModelWithOrder $model): ChangeModelOrderPositionInput
|
|
{
|
|
return new ChangeModelOrderPositionInput(
|
|
model: $model,
|
|
targetOrder: $this->integer('order'),
|
|
);
|
|
}
|
|
}
|