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\Http\Controllers\Controller;
|
|
use App\Lib\Helpers\RequestHelper;
|
|
use App\Models\Order;
|
|
use App\Queries\Orders\GetFoCustomerOrderDetailQuery;
|
|
use App\Queries\Orders\GetFoCustomerOrderDetailQueryInput;
|
|
use App\Queries\Orders\GetFoCustomerPaginatedOrdersQuery;
|
|
use App\Queries\Orders\GetFoCustomerPaginatedOrdersQueryInput;
|
|
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,
|
|
]);
|
|
}
|
|
}
|