feat: Part product images + seasonal tire-swap reminders

Part (HasMedia):
- Spatie media `image` single-file collection + imageUrl() helper
- PartResource form: image upload section (image editor, 2 MB max)
- Parts list: circular thumbnail column
- Shop catalog cards: square thumbnail + 📦 placeholder
- Shop part detail: 260px image alongside info, single column when no image

Seasonal tire-swap reminders:
- NotificationDispatcher::tireSeasonalSwap(TireSet) — Telegram first, email
  fallback (when set has a vehicle, via ServiceReminderMail with 'tire_swap'
  type and a size-aware note)
- tires:remind-seasonal artisan command, self-gating to Feb 15-Mar 15
  (notify winter sets stored) and Sep 15-Oct 15 (notify summer sets stored).
  60-day cooldown per client via service_reminders_sent. --force / --dry-run.
- Schedule: weekly Mon 09:30

Tests (6 new):
- outside window no-ops; spring window notifies winter; spring ignores summer;
  autumn notifies summer; cooldown blocks doubles; --force overrides window

Full suite: 106 passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 19:31:24 +00:00
parent b9ff9c6583
commit 8fdfc9ef85
9 changed files with 357 additions and 5 deletions
+37
View File
@@ -95,6 +95,43 @@ class NotificationDispatcher
]);
}
public function tireSeasonalSwap(\App\Models\Tenant\TireSet $set): bool
{
$company = $this->companyFor($set);
$client = $set->client;
if (! $client) return false;
return $this->dispatch($company, $client, 'reminder', [
'telegram' => fn () => $this->tgTireSeasonalSwap($set, $company, $client),
'email' => fn () => $set->vehicle ? $this->emailSafe(
fn () => Mail::to($client->email)->send(new ServiceReminderMail(
$set->vehicle,
'tire_swap',
'E timpul să schimbi anvelopele ' . ($set->season === 'winter' ? 'de iarnă' : 'de vară') .
' (' . $set->sizeLabel() . ').',
$company
)),
'tireSeasonalSwap', ['set' => $set->id]
) : false,
]);
}
protected function tgTireSeasonalSwap(\App\Models\Tenant\TireSet $set, Company $company, Client $client): bool
{
$brand = htmlspecialchars($company->display_name ?? $company->name);
$size = htmlspecialchars($set->sizeLabel());
$seasonRo = $set->season === 'winter' ? 'de iarnă' : 'de vară';
$loc = $set->currentStorage()?->location;
$plate = $set->vehicle?->plate ? ' · ' . htmlspecialchars($set->vehicle->plate) : '';
$text = "🔧 <b>Schimb sezonier anvelope</b>\n"
. "Setul tău {$seasonRo} ({$size}){$plate}"
. ($loc ? " e în depozit la <b>{$loc}</b>." : '.')
. "\n\nProgramează-te la <b>{$brand}</b>.";
return $this->telegram->sendMessage($company, (string) $client->telegram_chat_id, $text);
}
// ─── Channel dispatch ─────────────────────────────────────────
/**