This commit refactors the import statements in various controllers and jobs to improve code organization and readability. Unused imports were removed, and necessary imports were added to ensure proper functionality.
58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Fo\Customers;
|
|
|
|
use App\Contracts\Executor;
|
|
use App\Cqs\Queries\Orders\GetFoCustomerOrderDetailQuery;
|
|
use App\Cqs\Queries\Orders\GetFoCustomerOrderDetailQueryInput;
|
|
use App\Cqs\Queries\Orders\GetFoCustomerPaginatedOrdersQuery;
|
|
use App\Cqs\Queries\Orders\GetFoCustomerPaginatedOrdersQueryInput;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Lib\Helpers\RequestHelper;
|
|
use App\Models\Order;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\Request;
|
|
use Infrastructure\Adapters\Services\AppCustomerAuthService;
|
|
|
|
class OrderController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly AppCustomerAuthService $authService,
|
|
private readonly Executor $executor,
|
|
) {
|
|
}
|
|
|
|
public function index(Request $request, GetFoCustomerPaginatedOrdersQuery $query): View
|
|
{
|
|
$this->authorize('viewAnyOwn', Order::class);
|
|
|
|
$customer = $this->authService->getCustomerAsMandatory();
|
|
|
|
$orders = $this->executor->execute(
|
|
$query,
|
|
new GetFoCustomerPaginatedOrdersQueryInput(
|
|
customer: $customer,
|
|
pagination: RequestHelper::pagination($request),
|
|
),
|
|
);
|
|
|
|
return view('fo.customer.orders.index', compact('orders'));
|
|
}
|
|
|
|
public function show(Order $order, GetFoCustomerOrderDetailQuery $query): View
|
|
{
|
|
$this->authorize('viewOwn', $order);
|
|
|
|
$output = $this->executor->execute(
|
|
$query,
|
|
new GetFoCustomerOrderDetailQueryInput($order),
|
|
);
|
|
|
|
return view('fo.customer.orders.show', [
|
|
'order' => $output->order,
|
|
'mapUrl' => $output->mapUrl,
|
|
]);
|
|
}
|
|
}
|