領収証発行サービス
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

68 行
1.3KB

  1. <?php
  2. namespace App\Logic\ReceiptIssuingOrder;
  3. use App\Exceptions\AppCommonException;
  4. use App\Logic\SMS\SMSManager;
  5. use App\Models\ReceiptIssuingOrder;
  6. class UpdateManager extends ReceiptIssuingOrderManager
  7. {
  8. public function __construct(
  9. protected ReceiptIssuingOrder $order,
  10. protected SMSManager $smsManager
  11. ) {
  12. parent::__construct($order);
  13. }
  14. public function initByToken(string $token)
  15. {
  16. $ret = $this->checkToken($token);
  17. if (!$ret) {
  18. throw new AppCommonException("トークン不正");
  19. }
  20. $this->initialized = true;
  21. return $this;
  22. }
  23. public function initById(string $id)
  24. {
  25. $this->fetch($id);
  26. $this->initialized = true;
  27. return $this;
  28. }
  29. public function fill(array $attr)
  30. {
  31. $this->order->fill($attr);
  32. return $this;
  33. }
  34. protected function service()
  35. {
  36. $order = $this->order;
  37. // パラメータチェック
  38. $messages = $this->paramCheck();
  39. if (count($messages) !== 0) {
  40. return $messages;
  41. }
  42. // モデル更新
  43. $order->save();
  44. return [];
  45. }
  46. private function paramCheck(): array
  47. {
  48. $ret = [];
  49. $order = $this->order;
  50. return $ret;
  51. }
  52. }