<?php

namespace App\Actions\Setting;

use App\Events\ModelChanged;
use App\Models\Setting;
use App\Repositories\Contracts\SettingRepositoryInterface;

final class UpdateSettingsAction
{
    public function __construct(private SettingRepositoryInterface $repository) {}

    /**
     * @param  array<string, mixed>  $settings
     */
    public function execute(array $settings): void
    {
        $this->repository->bulkUpdate($settings);

        ModelChanged::dispatch(Setting::class, 'updated');
    }
}
