<?php

namespace App\Services\Equipment;

use App\Services\CommonService;
use App\Services\Customer\ClientService;

abstract class EquipmentService extends CommonService
{
    private ?ClientService $_clientService = null;
    public function __construct(mixed $request = null)
    {
        parent::__construct($request);
        $this->addClassName('Equipment');
    }

    final public function getClientService(): ClientService
    {
        if (!$this->_clientService) {
            $this->_clientService = new ClientService($this->request);
        }
        return $this->_clientService;
    }
    //FieldForm관련용
    public function getFormFieldOption(string $field, array $options = []): array
    {
        switch ($field) {
            case 'clientinfo_uid':
                $options = $this->getClientService()->getEntities();
                break;
            default:
                $options = parent::getFormFieldOption($field, $options);
                break;
        }
        return $options;
    }
}
