Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

50 rindas
1.2KB

  1. <?php
  2. namespace App\Http\Controllers\Web\Receipt;
  3. use App\Exceptions\AppCommonException;
  4. use App\Http\Controllers\Web\WebController;
  5. use App\Logic\ReceiptManager;
  6. use Auth;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Http\Response;
  9. class ReceiptDownloadController extends WebController
  10. {
  11. public function name(): string
  12. {
  13. return "領収証PDF取得";
  14. }
  15. public function description(): string
  16. {
  17. return "領収証PDFを取得する";
  18. }
  19. public function __construct(protected ReceiptDownloadParam $param)
  20. {
  21. parent::__construct();
  22. $this->middleware('auth:sanctum');
  23. }
  24. protected function run(Request $request): Response
  25. {
  26. $param = $this->param;
  27. $manager = new ReceiptManager($param->recordNo);
  28. if ($manager->getReceipt()->receiptNo !== $param->receiptNo) {
  29. throw new AppCommonException("パラメータ不正");
  30. }
  31. $customerCode = $manager->getReceipt()->customerCode;
  32. $customerCodeAuth = Auth::user()->kintone_customer_code;
  33. if ($customerCode != $customerCodeAuth) {
  34. throw new AppCommonException("パラメータ不正");
  35. }
  36. return $manager->getPdf();
  37. }
  38. }