領収証発行サービス
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

67 linhas
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. }
  13. public function initByToken(string $token)
  14. {
  15. $ret = $this->checkToken($token);
  16. if (!$ret) {
  17. throw new AppCommonException("トークン不正");
  18. }
  19. $this->initialized = true;
  20. return $this;
  21. }
  22. public function initById(string $id)
  23. {
  24. $this->fetch($id);
  25. $this->initialized = true;
  26. return $this;
  27. }
  28. public function fill(array $attr)
  29. {
  30. $this->order->fill($attr);
  31. return $this;
  32. }
  33. protected function service()
  34. {
  35. $order = $this->order;
  36. // パラメータチェック
  37. $messages = $this->paramCheck();
  38. if (count($messages) !== 0) {
  39. return $messages;
  40. }
  41. // モデル更新
  42. $order->save();
  43. return [];
  44. }
  45. private function paramCheck(): array
  46. {
  47. $ret = [];
  48. $order = $this->order;
  49. return $ret;
  50. }
  51. }