<?php

namespace App\Services\Customer;

use App\Entities\Customer\ServiceHistoryEntity;
use App\Models\Customer\ServiceHistoryModel;
use App\Services\Customer\ServiceService;

class ServiceHistoryService extends CustomerService
{
    private ?ServiceService $_serviceService = null;
    public function __construct(mixed $request = null)
    {
        parent::__construct($request);
        $this->addClassName('ServiceHistory');
    }
    public function getModelClass(): ServiceHistoryModel
    {
        return new ServiceHistoryModel();
    }
    public function getEntityClass(): ServiceHistoryEntity
    {
        return new ServiceHistoryEntity();
    }
    public function getServiceService(): ServiceService
    {
        if (!$this->_serviceService) {
            $this->_serviceService = new ServiceService($this->request);
        }
        return $this->_serviceService;
    }
    public function getFormFields(): array
    {
        return [
            "serviceinfo_uid",
            "title",
            "description",
        ];
    }
    public function getFilterFields(): array
    {
        return ["serviceinfo_uid", 'status'];
    }
    public function getBatchJobFields(): array
    {
        return ['status'];
    }
    public function getIndexFields(): array
    {
        return ['serviceinfo_uid', 'title', 'status', 'created_at'];
    }
    //FieldForm관련용
    public function getFormFieldOption(string $field, array $options = []): array
    {
        switch ($field) {
            case 'serviceinfo_uid':
                $options = $this->getServiceService()->getEntities();
                break;
            default:
                $options = parent::getFormFieldOption($field, $options);
                break;
        }
        return $options;
    }
}
