ldc-boutique-cnc-sable/app/Http/Controllers/Fo/Pages/HomeController.php

66 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers\Fo\Pages;
use App\Contracts\Executor;
use App\Http\Controllers\Controller;
use App\Queries\Products\GetPaginatedProductsQuery;
use App\Queries\Products\GetPaginatedProductsQueryInput;
use App\Queries\Ranges\GetPaginatedRangesQuery;
use App\Queries\Ranges\GetPaginatedRangesQueryInput;
use App\Queries\Slides\GetPaginatedSlidesQuery;
use App\Queries\Slides\GetPaginatedSlidesQueryInput;
use Domain\Models\ValueObjects\Pagination;
use Illuminate\Contracts\View\View;
use Infrastructure\Adapters\Services\AppCustomerAuthService;
class HomeController extends Controller
{
public function __construct(
private readonly AppCustomerAuthService $authService,
private readonly Executor $executor,
) {
}
public function index(
GetPaginatedProductsQuery $productsAction,
GetPaginatedSlidesQuery $slidesAction,
GetPaginatedRangesQuery $rangesAction
): View {
$starProductList = $this->executor->execute(
$productsAction,
new GetPaginatedProductsQueryInput(
Pagination::firstPage(),
starOnly: true,
publishedOnly: true,
withPricing: true,
)
)->items();
$slideList = $this->executor->execute(
$slidesAction,
new GetPaginatedSlidesQueryInput(
Pagination::firstPage(),
publishedOnly: true,
forConnectedCustomers: $this->authService->check()
)
)->items();
$rangeList = $this->executor->execute(
$rangesAction,
new GetPaginatedRangesQueryInput(
Pagination::firstPage(),
publishedOnly: true
)
)->items();
return view('fo.pages.home', compact(
'starProductList',
'slideList',
'rangeList'
));
}
}