src/Entity/Photo.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PhotoRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * @ORM\Entity(repositoryClass=PhotoRepository::class)
  11.  * @ORM\Table(indexes={@ORM\Index(columns={"influencer_id"})})
  12.  */
  13. class Photo
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\ManyToOne(targetEntity=Influencer::class, inversedBy="photos")
  23.      * @ORM\JoinColumn(nullable=false)
  24.      */
  25.     private $influencer;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="photos")
  28.      * @ORM\JoinColumn(nullable=false)
  29.      */
  30.     private $user;
  31.     /**
  32.      * @ORM\Column(type="string", length=255)
  33.      */
  34.     private $slug;
  35.     /**
  36.      * @ORM\Column(type="datetime_immutable")
  37.      */
  38.     private $created_at;
  39.     private $images = [];
  40.     /**
  41.      * @ORM\Column(type="boolean", nullable=true)
  42.      */
  43.     private $actif;
  44.     /**
  45.      * @ORM\Column(type="integer")
  46.      */
  47.     private $views;
  48.     /**
  49.      * @ORM\OneToMany(targetEntity=PhotoLike::class, mappedBy="photo", orphanRemoval=true)
  50.      */
  51.     private $photoLikes;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity=Comment::class, mappedBy="photo")
  54.      */
  55.     private $comments;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $webp;
  60.     /**
  61.      * @ORM\Column(type="boolean", nullable=true)
  62.      */
  63.     private $webpLarge;
  64.     /**
  65.      * @ORM\Column(type="string", length=45, nullable=true)
  66.      */
  67.     private $ip;
  68.     public function __construct()
  69.     {
  70.         $this->setActif(0);
  71.         $this->setViews(0);
  72.         $this->created_at = new \DateTimeImmutable();
  73.         $this->photoLikes = new ArrayCollection();
  74.         $this->comments = new ArrayCollection();
  75.     }
  76.     public function getId(): ?int
  77.     {
  78.         return $this->id;
  79.     }
  80.     public function getInfluencer(): ?Influencer
  81.     {
  82.         return $this->influencer;
  83.     }
  84.     public function setInfluencer(?Influencer $influencer): self
  85.     {
  86.         $this->influencer $influencer;
  87.         return $this;
  88.     }
  89.     public function getUser(): ?User
  90.     {
  91.         return $this->user;
  92.     }
  93.     public function setUser(?User $user): self
  94.     {
  95.         $this->user $user;
  96.         return $this;
  97.     }
  98.     public function getSlug(): ?string
  99.     {
  100.         return $this->slug;
  101.     }
  102.     public function setSlug(string $slug): self
  103.     {
  104.         $this->slug $slug;
  105.         return $this;
  106.     }
  107.     public function getCreatedAt(): ?\DateTimeImmutable
  108.     {
  109.         return $this->created_at;
  110.     }
  111.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  112.     {
  113.         $this->created_at $created_at;
  114.         return $this;
  115.     }
  116.     public function getImages()
  117.     {
  118.         return $this->images;
  119.     }
  120.     public function setImages($images)
  121.     {
  122.         $this->images $images;
  123.         return $this;
  124.     }
  125.     public function addImage($image)
  126.     {
  127.         $this->images[] = $image;
  128.         return $this;
  129.     }
  130.     public function getActif(): ?bool
  131.     {
  132.         return $this->actif;
  133.     }
  134.     public function setActif(?bool $actif): self
  135.     {
  136.         $this->actif $actif;
  137.         return $this;
  138.     }
  139.     public function getViews(): ?int
  140.     {
  141.         return $this->views;
  142.     }
  143.     public function setViews(int $views): self
  144.     {
  145.         $this->views $views;
  146.         return $this;
  147.     }
  148.     /**
  149.      * @return Collection<int, PhotoLike>
  150.      */
  151.     public function getPhotoLikes(): Collection
  152.     {
  153.         return $this->photoLikes;
  154.     }
  155.     /**
  156.      * @return Collection<int, PhotoLike>
  157.      */
  158.     public function getNbPhotoLikes(): int
  159.     {
  160.         return sizeof($this->getPhotoLikes());
  161.     }
  162.     public function addPhotoLike(PhotoLike $photoLike): self
  163.     {
  164.         if (!$this->photoLikes->contains($photoLike)) {
  165.             $this->photoLikes[] = $photoLike;
  166.             $photoLike->setPhoto($this);
  167.         }
  168.         return $this;
  169.     }
  170.     public function removePhotoLike(PhotoLike $photoLike): self
  171.     {
  172.         if ($this->photoLikes->removeElement($photoLike)) {
  173.             // set the owning side to null (unless already changed)
  174.             if ($photoLike->getPhoto() === $this) {
  175.                 $photoLike->setPhoto(null);
  176.             }
  177.         }
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection<int, Comment>
  182.      */
  183.     public function getComments(): Collection
  184.     {
  185.         return $this->comments;
  186.     }
  187.     public function getNbComments(): int
  188.     {
  189.         return sizeof($this->getComments());
  190.     }
  191.     public function addComment(Comment $comment): self
  192.     {
  193.         if (!$this->comments->contains($comment)) {
  194.             $this->comments[] = $comment;
  195.             $comment->setPhoto($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeComment(Comment $comment): self
  200.     {
  201.         if ($this->comments->removeElement($comment)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($comment->getPhoto() === $this) {
  204.                 $comment->setPhoto(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     public function getWebp(): ?string
  210.     {
  211.         return $this->webp;
  212.     }
  213.     public function setWebp(?string $webp): self
  214.     {
  215.         $this->webp $webp;
  216.         return $this;
  217.     }
  218.     public function isWebpLarge(): ?bool
  219.     {
  220.         return $this->webpLarge;
  221.     }
  222.     public function setWebpLarge(?bool $webpLarge): self
  223.     {
  224.         $this->webpLarge $webpLarge;
  225.         return $this;
  226.     }
  227.     public function getIp(): ?string
  228.     {
  229.         return $this->ip;
  230.     }
  231.     public function setIp(?string $ip): self
  232.     {
  233.         $this->ip $ip;
  234.         return $this;
  235.     }
  236. }