<?php

namespace lib\Services;

use lib\Entities\KCSEntity as Entity;
use lib\Models\KCSModel as Model;

class KCSService extends CommonService
{
  private ?Model $_model = null;
  public function __construct()
  {
    parent::__construct();
  }
  final public function getClassName(): string
  {
    return "KCS";
  }
  final public function getClassPath(): string
  {
    return $this->getClassName();
  }
  protected function getModel(): Model
  {
    if ($this->_model === null) {
      $this->_model = new Model();
      // $this->_model->setDebug(true);
    }
    return $this->_model;
  }

  public function getCountByServiceCode(string $service_code): int
  {
    $this->getModel()->where("service_code", $service_code);
    $count =  $this->getModel()->countAllResults();
    // echo "<BR>" . $this->getModel()->getLastQuery();
    return $count;
  }
}
