<?php

namespace App\Controllers\Admin\Customer;

use App\Controllers\Admin\AdminController;
use CodeIgniter\HTTP\RequestInterface;

use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Services\Customer\ServiceService;

abstract class CustomerController extends AdminController
{
    private ?ServiceService $_serviceService = null;
    public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
    {
        parent::initController($request, $response, $logger);
    }
    public function getServiceService(): ServiceService
    {
        if (!$this->_serviceService) {
            $this->_serviceService = new ServiceService($this->request);
        }
        return $this->_serviceService;
    }
    //Index,FieldForm관련

    //Service,ServicePaymentController사용
    //LINE,IP,SERVER등 추가 FilterOption 셋팅용
    final protected function setFilterOptionsByItemType(): void
    {
        //LINE,IP,SERVER등 추가 FilterOption 셋팅용
        foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
            $this->setFilterFieldOption($item_type, $this->getServiceService()->getFilterOptionsByItemType($item_type));
        }
    }
}
