<?php

namespace App\Observers;

use App\Core\Hook\HookBridge;
use App\Models\Product;

/**
 * ProductObserver
 *
 * Fires WHMCS-named action hooks on Product lifecycle events.
 */
class ProductObserver
{
    /**
     * Handle the Product "updated" event.
     * Fires: ProductEdit
     */
    public function updated(Product $product): void
    {
        $bridge = app(HookBridge::class);
        $bridge->fireAction('ProductEdit', $bridge->buildProductContext($product));
    }

    /**
     * Handle the Product "deleted" event.
     * Fires: ProductDelete
     */
    public function deleted(Product $product): void
    {
        $bridge = app(HookBridge::class);
        $bridge->fireAction('ProductDelete', $bridge->buildProductContext($product));
    }
}
