ldc-cocotte/app/Http/Requests/Bo/Dashboard/DashboardRequest.php
Jérémy Munsch d0efb0f527
refactor: update namespaces for actions and queries
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.
2026-11-10 15:13:26 +01:00

53 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests\Bo\Dashboard;
use App\Cqs\Queries\Dashboard\GetBoDashboardQueryInput;
use Carbon\CarbonInterface;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Date;
use Infrastructure\Adapters\Services\AppAdminAuthService;
class DashboardRequest extends FormRequest
{
public function __construct(
private readonly AppAdminAuthService $authService
) {
}
public function toGetBoDashboardQueryInput(): GetBoDashboardQueryInput
{
return new GetBoDashboardQueryInput(
start: $this->getStart(),
end: $this->getEnd(),
);
}
public function authorize(): bool
{
return $this->authService->check();
}
public function getStart(): ?CarbonInterface
{
return $this->has('start') ?
Date::parse($this->string('start')->value()) : null;
}
public function getEnd(): ?CarbonInterface
{
return $this->has('end') ?
Date::parse($this->string('end')->value()) : null;
}
/** @return array<string,mixed> */
public function rules(): array
{
return [
'start' => ['required_with:end', 'date'],
'end' => ['required_with:start', 'date'],
];
}
}