70 lines
2.4 KiB
PHP
70 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Entities\TrafficEntity;
|
|
use App\Forms\TrafficForm;
|
|
use App\Models\TrafficModel;
|
|
use DateTimeImmutable;
|
|
use DateTimeZone;
|
|
|
|
class TrafficService extends CommonService
|
|
{
|
|
public function __construct(
|
|
TrafficModel $model,
|
|
) {
|
|
parent::__construct($model);
|
|
$this->addClassPaths('Traffic');
|
|
}
|
|
public function getFormService(): TrafficForm
|
|
{
|
|
if ($this->formServiceInstance === null) {
|
|
$this->formServiceInstance = new TrafficForm();
|
|
$this->formServiceInstance->setAttributes([
|
|
'pk_field' => $this->model->getPKField(),
|
|
'title_field' => $this->model->getTitleField(),
|
|
'table' => $this->model->getTable(),
|
|
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
|
'class_path' => $this->getClassPaths(false)
|
|
]);
|
|
}
|
|
return $this->formServiceInstance;
|
|
}
|
|
public function getHelper(): TrafficHelper
|
|
{
|
|
if ($this->helperInstance === null) {
|
|
$this->helperInstance = new TrafficHelper();
|
|
$this->helperInstance->setAttributes([
|
|
'pk_field' => $this->model->getPKField(),
|
|
'title_field' => $this->model->getTitleField(),
|
|
'table' => $this->model->getTable(),
|
|
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
|
'class_path' => $this->getClassPaths(false)
|
|
]);
|
|
}
|
|
return $this->helperInstance;
|
|
}
|
|
//필수함수
|
|
// public function getNewServiceEntities(int $interval, string $status = DEFAULTS['STATUS']): array
|
|
// {
|
|
// return $this->getEntities(sprintf("start_at >= NOW()-INTERVAL {$interval} DAY AND status = '%s'", $status));
|
|
// }
|
|
// //서비스별 총 금액
|
|
// public function getTotalAmounts($where = []): array
|
|
// {
|
|
// $rows = $this->model->groupBy('clientinfo_uid')->select("clientinfo_uid,SUM(amount) AS amount")
|
|
// ->where($where)
|
|
// ->get()->getResult();
|
|
// $amounts = [];
|
|
// foreach ($rows as $row) {
|
|
// $amounts[$row->clientinfo_uid] = $row->amount;
|
|
// }
|
|
// return $amounts;
|
|
// }
|
|
// public function registerServiceAndGetId(array $context): array
|
|
// {
|
|
// $this->model->create($context);
|
|
// return $context;
|
|
// }
|
|
}
|