29 lines
984 B
PHP
29 lines
984 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace Modules\Core\Providers;
|
||
|
|
|
||
|
|
use Illuminate\Support\ServiceProvider;
|
||
|
|
use Lunar\Models\ProductOption;
|
||
|
|
use Lunar\Models\ProductOptionValue;
|
||
|
|
use Modules\Core\Catalog\Observers\ProductOptionReindexObserver;
|
||
|
|
use Modules\Core\Catalog\OptionTypes\ColorOptionType;
|
||
|
|
use Modules\Core\Catalog\Services\ProductOptionTypeManager;
|
||
|
|
|
||
|
|
class CatalogServiceProvider extends ServiceProvider
|
||
|
|
{
|
||
|
|
public function boot(): void
|
||
|
|
{
|
||
|
|
ProductOptionTypeManager::get()->register([
|
||
|
|
ColorOptionType::class,
|
||
|
|
]);
|
||
|
|
|
||
|
|
$observer = new ProductOptionReindexObserver;
|
||
|
|
|
||
|
|
ProductOption::saved(fn (ProductOption $option) => $observer->optionSaved($option));
|
||
|
|
ProductOption::deleted(fn (ProductOption $option) => $observer->optionDeleted($option));
|
||
|
|
|
||
|
|
ProductOptionValue::saved(fn (ProductOptionValue $value) => $observer->valueSaved($value));
|
||
|
|
ProductOptionValue::deleted(fn (ProductOptionValue $value) => $observer->valueDeleted($value));
|
||
|
|
}
|
||
|
|
}
|