<?php

declare(strict_types=1);

namespace App\Observers;

use App\Business\Product\ProductSkuLifecycleService;
use App\Models\DberpProduct;
use Illuminate\Support\Facades\Schema;

final class DberpProductObserver
{
    public function saved(DberpProduct $product): void
    {
        if (! Schema::hasTable('dberp_product_skus')) {
            return;
        }

        app(ProductSkuLifecycleService::class)->syncAfterProductSaved($product->fresh());
    }
}
