src/Entity/ProductImage.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Service\Helper\DateTimeHelper;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Exception;
  7. /**
  8.  * @ORM\Table(name="products__images", uniqueConstraints={
  9.  *     @ORM\UniqueConstraint(columns={"src", "product_id"})
  10.  *  })
  11.  * @ORM\Entity(repositoryClass="App\Repository\ProductImageRepository")
  12.  *
  13.  */
  14. class ProductImage
  15. {
  16.     use IdTrait;
  17.     /**
  18.      * @ORM\Column(name="created_at", type="datetime", nullable=false)
  19.      */
  20.     private DateTime $createdAt;
  21.     /**
  22.      * @ORM\ManyToOne(targetEntity="Product")
  23.      * @ORM\JoinColumn(name="product_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  24.      */
  25.     private Product $product;
  26.     /**
  27.      * @ORM\Column(name="src", type="string")
  28.      */
  29.     private string $src;
  30.     /**
  31.      * @ORM\Column(name="hash", type="string")
  32.      */
  33.     private string $hash;
  34.     /**
  35.      * @ORM\Column(name="published", type="boolean", nullable=false, options={"default":1})
  36.      */
  37.     private bool $published true;
  38.     /**
  39.      * @throws Exception
  40.      */
  41.     public function __construct(Product $productstring $srcstring $hash)
  42.     {
  43.         $this->product $product;
  44.         $this->src $src;
  45.         $this->hash $hash;
  46.         $this->createdAt DateTimeHelper::getNowDateTime();
  47.     }
  48.     public function getProduct(): Product
  49.     {
  50.         return $this->product;
  51.     }
  52.     public function getSrc(): string
  53.     {
  54.         return $this->src;
  55.     }
  56.     public function isPublished(): bool
  57.     {
  58.         return $this->published;
  59.     }
  60.     public function setPublished(bool $published): void
  61.     {
  62.         $this->published $published;
  63.     }
  64.     public function getHash(): string
  65.     {
  66.         return $this->hash;
  67.     }
  68. }