Add functionality to change the order of models in the product list. This includes new actions, requests, and UI components for user interaction.
42 lines
1,005 B
PHP
42 lines
1,005 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Bo;
|
|
|
|
use App\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'),
|
|
);
|
|
}
|
|
}
|