account pages: login, order history, order details, account details, wishlist

This commit is contained in:
elvira
2026-09-24 17:27:58 +03:00
parent 580adac33a
commit cf3681260b
42 changed files with 1972 additions and 15 deletions
@@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\Account;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\View\View;
use Modules\Core\Payment\Models\PaymentMethod;
use Modules\Core\Customer\Exceptions\OrderNotFoundException;
use Modules\Core\Customer\Services\CustomerAccountService;
/**
* Order history. Every lookup goes through CustomerAccountService, which only
* ever returns the logged-in user's own placed orders, so an order id from
* the URL can't reach someone else's order.
*/
class OrderController extends Controller
{
public function __construct(
private readonly CustomerAccountService $account,
) {}
public function index(string $locale, Request $request): View
{
return view('account.orders.index', [
'orders' => $this->account->orders($request->user(), 15),
]);
}
public function show(string $locale, Request $request, int $orderId): View
{
try {
$order = $this->account->order($request->user(), $orderId);
} catch (OrderNotFoundException) {
abort(404);
}
// By type, like the checkout confirmation: the method may since have
// been disabled, but the order still shows what was used.
$paymentMethodName = PaymentMethod::where('type', $order->meta['payment_method'] ?? null)
->first()
?->translate('name');
return view('account.orders.show', [
'order' => $order,
'paymentMethodName' => $paymentMethodName,
'shipments' => $order->shipments->whereNull('cancelled_at')->whereNotNull('tracking_reference'),
]);
}
}