<?php

namespace App\Listeners;

use App\Services\AutoTraderHub;
use App\Traits\EnsuresVehicleAttribute;
use Mtc\MercuryDataModels\Events\SettingUpdated;

class CreateVehicleIsPreRegAttribute
{
    use EnsuresVehicleAttribute;

    public function __construct(private readonly AutoTraderHub $autoTraderHub)
    {
        //
    }

    public function handle(SettingUpdated $event)
    {
        if ($event->setting->config_key === 'vehicles-pre-reg-condition-enabled' && $event->setting->value) {
            $this->getVehicleAttribute(
                'Pre-Reg vehicle',
                'boolean',
                'is-pre-reg',
            );
        }
    }
}
