feat: shop UX polish — password reset / order email / multi-image / customer admin

Shop password reset:
- Configured 'shop_customers' password broker on the existing
  password_reset_tokens table
- ShopCustomer::sendPasswordResetNotification overrides Laravel default to
  send a ShopPasswordResetMail with a tenant-subdomain reset URL
- Routes /shop/password/forgot, /shop/password/email, /shop/password/reset/{token}
  + ShopAuthController showForgotPassword/sendResetLink/showResetPassword/
  resetPassword. Forgot view stays generic ("if it exists, we sent…") to avoid
  email enumeration. Login view links to "Am uitat parola".

Order confirmation email:
- ShopOrderConfirmationMail + nicely formatted HTML email template
- ShopOrderNotifier::placed now also emails customer_email (best-effort,
  warning-only logged on failure) alongside existing Telegram + staff push

Multiple images per Part:
- Part media collection switched from singleFile to multiple (max 8 in form)
- imageUrls() helper for galleries; imageUrl() still returns first for cards
- PartResource form: reorderable multi-upload
- Shop part detail: vertical thumbnails switch the main image via vanilla JS

ShopCustomerResource (tenant Filament, "Magazin" nav group):
- List with name/phone/email/client_id/orders_count/last_login_at
- Edit (no password field exposed)
- "Trimite reset parolă" action uses the new broker
- OrdersRelationManager shows the customer's orders read-only

Tests (7 new):
- forgot sends mail; forgot doesn't disclose unknown email; reset with valid
  token changes password; bad token rejected; order email when customer_email
  set; email skipped without it; Part has imageUrls() collection

Full suite: 130 passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-03 06:14:45 +00:00
parent fca4f75e9c
commit 3da1f5412a
20 changed files with 703 additions and 8 deletions
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Comandă primită</title>
</head>
<body style="font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; max-width: 600px; margin: 0 auto; padding: 24px; color: #1f2937;">
@php $brand = $company->display_name ?? $company->name; @endphp
<h2 style="font-size: 22px; margin-bottom: 4px;">{{ $brand }}</h2>
<p style="color: #6b7280; margin-bottom: 24px;">Comanda ta a fost primită cu succes.</p>
<div style="background: #f9fafb; border-radius: 10px; padding: 18px; margin-bottom: 18px;">
<div style="font-size: 14px; color: #6b7280;">Comanda</div>
<div style="font-size: 22px; font-weight: 700; margin-bottom: 8px;">#{{ $order->number }}</div>
<div style="color: #6b7280; font-size: 13px;">
{{ $order->created_at->isoFormat('D MMM YYYY, HH:mm') }} ·
{{ \App\Models\Tenant\OnlineOrder::DELIVERY[$order->delivery_method] ?? $order->delivery_method }}
</div>
</div>
<h3 style="font-size: 16px; margin-bottom: 8px;">Produsele tale</h3>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 18px; font-size: 14px;">
@foreach ($items as $item)
<tr>
<td style="padding: 8px 0; border-bottom: 1px solid #f3f4f6;">
{{ $item->name }}
<span style="color: #9ca3af;"> × {{ rtrim(rtrim(number_format((float) $item->qty, 2), '0'), '.') }}</span>
</td>
<td style="padding: 8px 0; border-bottom: 1px solid #f3f4f6; text-align: right;">
{{ number_format((float) $item->total, 2) }} {{ $currency }}
</td>
</tr>
@endforeach
@if ((float) $order->delivery_fee > 0)
<tr>
<td style="padding: 8px 0; color: #6b7280;">Livrare</td>
<td style="padding: 8px 0; text-align: right;">{{ number_format((float) $order->delivery_fee, 2) }} {{ $currency }}</td>
</tr>
@endif
<tr>
<td style="padding: 12px 0 4px; font-weight: 700;">Total</td>
<td style="padding: 12px 0 4px; font-weight: 700; font-size: 18px; text-align: right;">
{{ number_format((float) $order->total, 2) }} {{ $currency }}
</td>
</tr>
</table>
@if ($order->address)
<p style="background: #fefce8; border-left: 3px solid #facc15; padding: 10px 12px; font-size: 13px; color: #713f12;">
<strong>Adresă livrare:</strong> {{ $order->address }}
</p>
@endif
<p style="margin: 24px 0;">
<a href="{{ $trackingUrl }}" style="display: inline-block; background: #3b82f6; color: #fff; padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: 600;">
Urmărește comanda
</a>
</p>
<p style="color: #9ca3af; font-size: 12px; border-top: 1px solid #e5e7eb; padding-top: 12px; margin-top: 32px;">
Email automat de la {{ $brand }} nu răspunde la el. Pentru întrebări, sună la {{ $company->phone ?? '—' }}.
</p>
</body>
</html>
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Resetare parolă</title>
</head>
<body style="font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; max-width: 560px; margin: 0 auto; padding: 24px; color: #1f2937;">
@php $brand = $company->display_name ?? $company->name; @endphp
<h2 style="font-size: 22px; margin-bottom: 16px;">{{ $brand }}</h2>
<p>Salut {{ $customer->name }},</p>
<p>Ai cerut resetarea parolei pentru contul tău de magazin. Apasă linkul de mai jos ca setezi o parolă nouă:</p>
<p style="margin: 24px 0;">
<a href="{{ $resetUrl }}" style="display: inline-block; background: #3b82f6; color: #fff; padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: 600;">
Resetează parola
</a>
</p>
<p style="color: #6b7280; font-size: 14px;">Linkul expiră în 60 de minute. Dacă nu ai cerut tu acest reset, ignoră emailul contul tău e în siguranță.</p>
<p style="color: #9ca3af; font-size: 12px; margin-top: 32px; border-top: 1px solid #e5e7eb; padding-top: 12px;">
Email automat de la {{ $brand }} nu răspunde la el.
</p>
</body>
</html>
@@ -0,0 +1,35 @@
@extends('shop.layout')
@section('title', 'Resetare parolă')
@section('content')
<div style="max-width:380px;margin:0 auto;">
<h1 style="font-size:22px;margin-bottom:8px;">Am uitat parola</h1>
<p class="muted" style="margin-bottom:16px;">Introdu emailul cu care te-ai înregistrat îți trimitem un link de resetare.</p>
@if (session('status'))
<div class="card" style="border-color:#bbf7d0;background:#f0fdf4;margin-bottom:14px;color:#166534;font-size:14px;">
{{ session('status') }}
</div>
@endif
@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
<form method="POST" action="/shop/password/email" class="card">
@csrf
<div class="field"><label>Email *</label>
<input type="email" name="email" value="{{ old('email') }}" required autofocus>
</div>
<button type="submit" class="btn block">Trimite link resetare</button>
</form>
<p class="muted" style="text-align:center;margin-top:12px;">
<a href="/shop/login" style="color:inherit;text-decoration:underline;"> Înapoi la login</a>
</p>
</div>
@endsection
+7 -1
View File
@@ -25,7 +25,13 @@
</form>
<p class="muted" style="text-align:center;margin-top:12px;">
Nu ai cont? <a href="/shop/register" style="color:inherit;text-decoration:underline;">Înregistrare</a>
<a href="/shop/password/forgot" style="color:inherit;text-decoration:underline;">Am uitat parola</a>
· Nu ai cont? <a href="/shop/register" style="color:inherit;text-decoration:underline;">Înregistrare</a>
</p>
@if (session('status'))
<div class="card" style="border-color:#bbf7d0;background:#f0fdf4;margin-top:14px;color:#166534;font-size:14px;text-align:center;">
{{ session('status') }}
</div>
@endif
</div>
@endsection
+31
View File
@@ -0,0 +1,31 @@
@extends('shop.layout')
@section('title', 'Parolă nouă')
@section('content')
<div style="max-width:380px;margin:0 auto;">
<h1 style="font-size:22px;margin-bottom:16px;">Setează o parolă nouă</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
<form method="POST" action="/shop/password/reset" class="card">
@csrf
<input type="hidden" name="token" value="{{ $token }}">
<div class="field"><label>Email *</label>
<input type="email" name="email" value="{{ old('email', $email) }}" required readonly style="background:#f9fafb;">
</div>
<div class="field"><label>Parolă nouă *</label>
<input type="password" name="password" required minlength="6" autofocus>
</div>
<div class="field"><label>Confirmă parola *</label>
<input type="password" name="password_confirmation" required minlength="6">
</div>
<button type="submit" class="btn block">Setează parola</button>
</form>
</div>
@endsection
+32 -5
View File
@@ -1,14 +1,41 @@
@extends('shop.layout')
@section('title', $part->name)
@section('content')
@php $currency = $tenant->settings['currency'] ?? 'MDL'; $stock = (float) $part->qty; $img = $part->imageUrl(); @endphp
@php
$currency = $tenant->settings['currency'] ?? 'MDL';
$stock = (float) $part->qty;
$imgs = $part->imageUrls();
@endphp
<a href="/shop" class="muted"> Înapoi la catalog</a>
@if ($img)
<div class="card" style="margin-top:12px;display:grid;grid-template-columns:260px 1fr;gap:20px;align-items:start;">
<div style="border-radius:10px;overflow:hidden;aspect-ratio:1;background:#f9fafb;border:1px solid #e5e7eb;">
<img src="{{ $img }}" alt="{{ $part->name }}" style="width:100%;height:100%;object-fit:cover;display:block;">
@if (! empty($imgs))
<div class="card" style="margin-top:12px;display:grid;grid-template-columns:280px 1fr;gap:20px;align-items:start;">
<div>
<div style="border-radius:10px;overflow:hidden;aspect-ratio:1;background:#f9fafb;border:1px solid #e5e7eb;">
<img id="gallery-main" src="{{ $imgs[0] }}" alt="{{ $part->name }}" style="width:100%;height:100%;object-fit:cover;display:block;">
</div>
@if (count($imgs) > 1)
<div style="display:flex;gap:6px;margin-top:8px;flex-wrap:wrap;">
@foreach ($imgs as $i => $url)
<button type="button" data-gallery-src="{{ $url }}" data-gallery-index="{{ $i }}"
class="gallery-thumb {{ $i === 0 ? 'thumb-active' : '' }}"
style="width:54px;height:54px;border-radius:6px;overflow:hidden;padding:0;cursor:pointer;background:#f9fafb;border:1px solid #e5e7eb;">
<img src="{{ $url }}" style="width:100%;height:100%;object-fit:cover;display:block;">
</button>
@endforeach
</div>
<style>.thumb-active { border: 2px solid #3b82f6 !important; }</style>
<script>
document.querySelectorAll('.gallery-thumb').forEach(btn => {
btn.addEventListener('click', () => {
document.getElementById('gallery-main').src = btn.dataset.gallerySrc;
document.querySelectorAll('.gallery-thumb').forEach(b => b.classList.remove('thumb-active'));
btn.classList.add('thumb-active');
});
});
</script>
@endif
</div>
<div>
@else