75386c354a
Schema: - shop_customers (company_id, name, phone unique-per-tenant, email, password, client_id auto-linked, last_login_at) - online_orders.shop_customer_id nullable FK Auth: - New 'shop' guard (session driver, shop_customers provider) in config/auth.php - ShopCustomer Authenticatable with hashed password cast and BelongsToTenant global scope — login attempts naturally scoped to current tenant subdomain Flow: - ShopAuthController: register / login / logout / account - Register auto-links to existing Client by phone match - /shop/account: order history (only the logged customer's orders) + profile - Checkout prefills name/phone/email from logged customer + sets shop_customer_id (and client_id from auto-link) on the placed order - Layout nav switches between Login/Register and "👤 Name + Ieșire" Tests (8 new): - register creates customer + auto-login - register auto-links existing Client by phone - duplicate phone rejected - login validates credentials - /account requires auth (redirects to /shop/login) - /account lists only the logged customer's orders - checkout attaches shop_customer_id - customers tenant-isolated Full suite: 117 passed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
72 lines
2.9 KiB
PHP
72 lines
2.9 KiB
PHP
@extends('shop.layout')
|
||
@section('title', 'Finalizare comandă')
|
||
@section('content')
|
||
@php
|
||
$currency = $tenant->settings['currency'] ?? 'MDL';
|
||
$labels = \App\Models\Tenant\OnlineOrder::DELIVERY;
|
||
@endphp
|
||
|
||
<h1 style="font-size:22px;margin-bottom:16px;">Finalizează comanda</h1>
|
||
|
||
@if ($errors->any())
|
||
<div class="card" style="border-color:#fca5a5;background:#fef2f2;margin-bottom:14px;">
|
||
<ul style="margin:0;padding-left:18px;color:#991b1b;font-size:14px;">
|
||
@foreach ($errors->all() as $e)<li>{{ $e }}</li>@endforeach
|
||
</ul>
|
||
</div>
|
||
@endif
|
||
|
||
<div style="display:grid;grid-template-columns:1fr 320px;gap:18px;align-items:start;">
|
||
<form method="POST" action="/shop/checkout" class="card">
|
||
@csrf
|
||
<div class="field">
|
||
<label>Nume complet *</label>
|
||
<input type="text" name="customer_name" value="{{ old('customer_name', ($customer ?? null)?->name) }}" required>
|
||
</div>
|
||
<div class="field">
|
||
<label>Telefon *</label>
|
||
<input type="text" name="customer_phone" value="{{ old('customer_phone', ($customer ?? null)?->phone) }}" required placeholder="+373…">
|
||
</div>
|
||
<div class="field">
|
||
<label>Email</label>
|
||
<input type="email" name="customer_email" value="{{ old('customer_email', ($customer ?? null)?->email) }}">
|
||
</div>
|
||
<div class="field">
|
||
<label>Livrare *</label>
|
||
<select name="delivery_method" required>
|
||
@foreach ($deliveryOptions as $opt)
|
||
<option value="{{ $opt }}">{{ $labels[$opt] ?? $opt }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
<div class="field">
|
||
<label>Adresă (pentru curier/poștă)</label>
|
||
<input type="text" name="address" value="{{ old('address') }}">
|
||
</div>
|
||
<div class="field">
|
||
<label>Observații</label>
|
||
<textarea name="notes" rows="2">{{ old('notes') }}</textarea>
|
||
</div>
|
||
<button class="btn block" type="submit">Plasează comanda</button>
|
||
</form>
|
||
|
||
<div class="card">
|
||
<h3 style="font-size:15px;margin-bottom:10px;">Sumar</h3>
|
||
<table class="cart">
|
||
@foreach ($cart as $item)
|
||
<tr>
|
||
<td>{{ $item['name'] }} <span class="muted">×{{ $item['qty'] }}</span></td>
|
||
<td class="r">{{ number_format($item['price'] * $item['qty'], 2) }}</td>
|
||
</tr>
|
||
@endforeach
|
||
</table>
|
||
<div style="margin-top:12px;font-size:18px;font-weight:700;text-align:right;">
|
||
{{ number_format($subtotal, 2) }} {{ $currency }}
|
||
</div>
|
||
<p class="muted" style="margin-top:6px;">Taxa de livrare se calculează în funcție de metoda aleasă.</p>
|
||
</div>
|
||
</div>
|
||
|
||
<style>@media (max-width:720px){ .wrap div[style*="grid-template-columns:1fr 320px"]{ grid-template-columns:1fr !important; } }</style>
|
||
@endsection
|