|
- <?php
-
- namespace App\Logic;
-
- use App\Features\InstanceAble;
- use App\Kintone\Models\Ask;
- use App\Kintone\Models\Customer;
- use App\Util\DateUtil;
- use LogicException;
-
- class AskManager
- {
-
- use InstanceAble;
-
- private Customer|null $customer = null;
-
- public function __construct(private Ask $model)
- {
- }
-
- public function setCustomer(Customer $customer): static
- {
- $this->customer = $customer;
- return $this;
- }
-
-
- public function make(string $genre, string $ask)
- {
- if ($this->customer === null) {
- throw new LogicException("顧客NULL");
- }
-
- $this->model->set(Ask::FIELD_ASK_DATETIME, DateUtil::now());
- $this->model->set(Ask::FIELD_GENRE, $genre);
- $this->model->set(Ask::FIELD_ASK, $ask);
- $this->model->set(Ask::FIELD_CUSTOMER_CODE, $this->customer->getStr(Customer::FIELD_CUSTOMER_CODE));
-
- return $this->model;
- }
- }
|