src/Entity/Image/ImgPublication.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Image;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * ImgPublication
  8.  */
  9. #[ORM\Table(name'img_publication')]
  10. #[ORM\Entity(repositoryClass\App\Repository\Image\ImgPublicationRepository::class)]
  11. class ImgPublication implements \Stringable
  12. {
  13.     #[ORM\Column(name'id'type'integer')]
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue(strategy'AUTO')]
  16.     private ?int $id null;
  17.     #[ORM\Column(name'name'type'string'length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(name'active'type'boolean')]
  20.     private ?bool $active null;
  21.     #[ORM\ManyToMany(targetEntity\App\Entity\Image\Image::class, mappedBy'imgPublications')]
  22.     private $images;
  23.     public function __construct()
  24.     {
  25.         $this->images = new ArrayCollection();
  26.     }
  27.     /**
  28.      * Get id.
  29.      *
  30.      * @return int
  31.      */
  32.     public function getId()
  33.     {
  34.         return $this->id;
  35.     }
  36.     /**
  37.      * Set name.
  38.      *
  39.      * @param string $name
  40.      *
  41.      * @return ImgPublication
  42.      */
  43.     public function setName($name)
  44.     {
  45.         $this->name $name;
  46.         return $this;
  47.     }
  48.     /**
  49.      * Get name.
  50.      *
  51.      * @return string
  52.      */
  53.     public function getName()
  54.     {
  55.         return $this->name;
  56.     }
  57.     /**
  58.      * Set active.
  59.      *
  60.      * @param bool $active
  61.      *
  62.      * @return ImgPublication
  63.      */
  64.     public function setActive($active)
  65.     {
  66.         $this->active $active;
  67.         return $this;
  68.     }
  69.     /**
  70.      * Get active.
  71.      *
  72.      * @return bool
  73.      */
  74.     public function getActive()
  75.     {
  76.         return $this->active;
  77.     }
  78.     /**
  79.      * @return Collection|Article[]
  80.      */
  81.     public function getImages(): Collection
  82.     {
  83.         return $this->images;
  84.     }
  85.     public function addImage(Image $image): self
  86.     {
  87.         if (!$this->images->contains($image)) {
  88.             $this->images[] = $image;
  89.             $image->addImgPublication($this);
  90.         }
  91.         return $this;
  92.     }
  93.     public function removeImage(Image $image): self
  94.     {
  95.         if ($this->images->contains($image)) {
  96.             $this->images->removeElement($image);
  97.             $image->removeImgPublication($this);
  98.         }
  99.         return $this;
  100.     }
  101.     public function __toString(): string
  102.     {
  103.         Return $this->name;
  104.     }
  105. }