product_brochure.php 363 B

12345678910111213141516171819
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. use RuntimeException;
  4. /**
  5. * @var int $id
  6. */
  7. $product = Product::require($id);
  8. if($product->hasBrochure()) {
  9. header("Content-Type: application/pdf");
  10. readfile($product->getBrochurePath());
  11. exit(0);
  12. }
  13. http_response_code(404);
  14. throw new RuntimeException(__("Brochure not found."));