<?php
 namespace App\Observers; use App\Core\Hook\HookBridge; use App\Models\SavedPaymentMethod; class SavedPaymentMethodObserver { public function created(SavedPaymentMethod $method): void { $this->fireCcUpdate($method, 'created'); } public function updated(SavedPaymentMethod $method): void { if (! $method->wasChanged(['token', 'card_brand', 'last_four', 'expiry_month', 'expiry_year'])) { return; } $this->fireCcUpdate($method, 'updated'); } private function fireCcUpdate(SavedPaymentMethod $method, string $action): void { app(HookBridge::class)->fireAction('CCUpdate', [ 'userid' => $method->client_id, 'user_id' => $method->client_id, 'client_id' => $method->client_id, 'saved_payment_method_id' => $method->id, 'gateway' => $method->gateway_slug, 'card_brand' => $method->card_brand, 'last_four' => $method->last_four, 'expiry_month' => $method->expiry_month, 'expiry_year' => $method->expiry_year, 'action' => $action, ]); } } 