You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.5KB

  1. <?php
  2. namespace App\Http\Controllers\Web\Pdf\QRService;
  3. use App\Http\Controllers\Web\WebController;
  4. use App\Models\HtpmsCustomer\Mst\Shop;
  5. use App\Models\HtpmsCustomer\QRService\AcquisitionTicketToken;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Http\Response;
  8. use PDF;
  9. class AcquisitionAnnouncementController extends WebController
  10. {
  11. public function name(): string
  12. {
  13. return "QRサービス券取得用ページ取得";
  14. }
  15. public function description(): string
  16. {
  17. return "QRサービス券取得用ページを取得する";
  18. }
  19. public function __construct(protected AcquisitionAnnouncementParam $param)
  20. {
  21. parent::__construct();
  22. }
  23. protected function run(Request $request): Response
  24. {
  25. $shopId = $this->sessionUser->shopId();
  26. $shop = Shop::findOrFail($shopId);
  27. $token = AcquisitionTicketToken::whereShopId($shopId)
  28. ->firstOrFail();
  29. $url = implode("/", [
  30. config('app.url'),
  31. "qr-service",
  32. "acquisition",
  33. $token->token,
  34. ]);
  35. $pdf = PDF::loadView("pdf/qr-service/acquisition_announcement", [
  36. "url" => $url,
  37. "shopName" => $shop->name,
  38. ]);
  39. $filename = "acquisition_announcement.pdf";
  40. $ret = $pdf->setPaper("A4")
  41. ->setOption('encoding', 'utf-8')
  42. ->inline()
  43. ->header("Content-Disposition", sprintf('inline; filename=%s', $filename));
  44. return $ret;
  45. }
  46. }