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

55 行
1.2KB

  1. <?php
  2. namespace App\Logic\ReceiptIssuingOrder;
  3. use App\Codes\ReceiptIssuingOrderStatus;
  4. use App\Exceptions\AppCommonException;
  5. use App\Models\ReceiptIssuingOrder;
  6. use PDF;
  7. class PDFDownLoadManager extends ReceiptIssuingOrderManager
  8. {
  9. public function __construct(
  10. protected ReceiptIssuingOrder $order,
  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 service()
  30. {
  31. $order = $this->order;
  32. $pdf = PDF::loadView('pdf', $order);
  33. // はがきサイズを指定
  34. $ret = $pdf->setOption('page-height', 148)
  35. ->setOption('page-width', 100)
  36. ->setOption('encoding', 'utf-8')
  37. ->inline();
  38. $order->status = ReceiptIssuingOrderStatus::DOWNLOAD_DONE;
  39. $order->save();
  40. return $ret;
  41. }
  42. }