55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Fo\Customers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Order;
|
|
use App\Services\MapUrlService;
|
|
use App\Services\OrderService;
|
|
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 OrderService $orderService,
|
|
private readonly MapUrlService $mapUrlService,
|
|
) {
|
|
}
|
|
|
|
public function index(Request $request): View
|
|
{
|
|
$this->authorize('viewAnyOwn', Order::class);
|
|
|
|
$customer = $this->authService->getCustomerAsMandatory();
|
|
|
|
$pagination = $request->pagination();
|
|
|
|
$orders = $this->orderService->paginateOrdersFor(
|
|
$customer,
|
|
$pagination,
|
|
);
|
|
|
|
return view('fo.customer.orders.index', compact(
|
|
'orders'
|
|
));
|
|
}
|
|
|
|
public function show(Order $order): View
|
|
{
|
|
$this->authorize('viewOwn', $order);
|
|
|
|
$order->load(['lines']);
|
|
|
|
$mapUrl = $this->mapUrlService->generateUrl($order->delivery_address);
|
|
|
|
return view('fo.customer.orders.show', compact(
|
|
'order',
|
|
'mapUrl'
|
|
));
|
|
}
|
|
}
|