<?php
namespace App\Entity;
use App\Repository\PhotoRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=PhotoRepository::class)
* @ORM\Table(indexes={@ORM\Index(columns={"influencer_id"})})
*/
class Photo
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Influencer::class, inversedBy="photos")
* @ORM\JoinColumn(nullable=false)
*/
private $influencer;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="photos")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $created_at;
private $images = [];
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $actif;
/**
* @ORM\Column(type="integer")
*/
private $views;
/**
* @ORM\OneToMany(targetEntity=PhotoLike::class, mappedBy="photo", orphanRemoval=true)
*/
private $photoLikes;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="photo")
*/
private $comments;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $webp;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $webpLarge;
/**
* @ORM\Column(type="string", length=45, nullable=true)
*/
private $ip;
public function __construct()
{
$this->setActif(0);
$this->setViews(0);
$this->created_at = new \DateTimeImmutable();
$this->photoLikes = new ArrayCollection();
$this->comments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getInfluencer(): ?Influencer
{
return $this->influencer;
}
public function setInfluencer(?Influencer $influencer): self
{
$this->influencer = $influencer;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getImages()
{
return $this->images;
}
public function setImages($images)
{
$this->images = $images;
return $this;
}
public function addImage($image)
{
$this->images[] = $image;
return $this;
}
public function getActif(): ?bool
{
return $this->actif;
}
public function setActif(?bool $actif): self
{
$this->actif = $actif;
return $this;
}
public function getViews(): ?int
{
return $this->views;
}
public function setViews(int $views): self
{
$this->views = $views;
return $this;
}
/**
* @return Collection<int, PhotoLike>
*/
public function getPhotoLikes(): Collection
{
return $this->photoLikes;
}
/**
* @return Collection<int, PhotoLike>
*/
public function getNbPhotoLikes(): int
{
return sizeof($this->getPhotoLikes());
}
public function addPhotoLike(PhotoLike $photoLike): self
{
if (!$this->photoLikes->contains($photoLike)) {
$this->photoLikes[] = $photoLike;
$photoLike->setPhoto($this);
}
return $this;
}
public function removePhotoLike(PhotoLike $photoLike): self
{
if ($this->photoLikes->removeElement($photoLike)) {
// set the owning side to null (unless already changed)
if ($photoLike->getPhoto() === $this) {
$photoLike->setPhoto(null);
}
}
return $this;
}
/**
* @return Collection<int, Comment>
*/
public function getComments(): Collection
{
return $this->comments;
}
public function getNbComments(): int
{
return sizeof($this->getComments());
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setPhoto($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getPhoto() === $this) {
$comment->setPhoto(null);
}
}
return $this;
}
public function getWebp(): ?string
{
return $this->webp;
}
public function setWebp(?string $webp): self
{
$this->webp = $webp;
return $this;
}
public function isWebpLarge(): ?bool
{
return $this->webpLarge;
}
public function setWebpLarge(?bool $webpLarge): self
{
$this->webpLarge = $webpLarge;
return $this;
}
public function getIp(): ?string
{
return $this->ip;
}
public function setIp(?string $ip): self
{
$this->ip = $ip;
return $this;
}
}