initialized) { throw new LogicException("初期化ミス"); } if ($this->order->contract_id !== $newHandler->contract_id) { throw new AppCommonException('契約不正'); } $this->order->handler_id = $newHandler->id; ChangeHandlerEvent::dispatch($this->order); return $this; } /** * 郵送依頼 * * @param array $attr * @return static */ public function mailOrder(array $attr): static { $this->fill($attr); // イベント登録 MailOrderEvent::dispatch($this->order); return $this; } /** * 郵送投函完了 * * @param array $attr * @return static */ public function mailPosted(Carbon $postDate): static { $this->order->status_mail_post_date = $postDate; // イベント登録 MailPostedEvent::dispatch($this->order); return $this; } /** * 領収証確定 * * @return static */ public function setConfirm(): static { if ($this->order->receipt_no !== null) { throw new LogicException("領収証確定済み変更検知"); } $this->order->receipt_no = $this->generateReceiptnNo(); $this->order->status_receipt_confirm_datetime = DateUtil::now(); // イベント登録 ConfirmedEvent::dispatch($this->order); return $this; } public function fill(array $attr) { $this->order->fill($attr); return $this; } public function update() { // モデル更新 $this->save(); return []; } }