<?php

namespace App\Traits\Outlet;

use App\Livewire\Forms\Studio\Master\OutletForm;

trait WithFacilityHandler
{
    public OutletForm $form;

    public function addFacility()
    {
        $this->form->facilities[] = '';
    }

    public function removeFacility(int $index)
    {
        unset($this->form->facilities[$index]);
        $this->form->facilities = array_values($this->form->facilities);

        if (empty($this->form->facilities)) {
            $this->form->facilities = [''];
        }
    }
}
