<?php
namespace App\Entity;
use App\Repository\VideoRepository;
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=VideoRepository::class)
* @ORM\Table(indexes={@ORM\Index(columns={"influencer_id"})})
*/
class Video
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Influencer::class, inversedBy="videos")
* @ORM\JoinColumn(nullable=false)
*/
private $influencer;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="videos")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* @ORM\Column(type="string", length=255)
*/
private $embed;
/**
* @ORM\Column(type="boolean")
*/
private $actif;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $created_at;
/**
* @ORM\Column(type="datetime")
*/
private $updated_at;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @Assert\File(maxSize="2147483648")
*/
private $video;
/**
* @ORM\Column(type="integer")
*/
private $views;
/**
* @ORM\Column(type="boolean")
*/
private $uploaded;
/**
* @ORM\Column(type="string", length=255)
*/
private $filecode;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="video")
*/
private $comments;
/**
* @ORM\OneToMany(targetEntity=PhotoLike::class, mappedBy="video")
*/
private $photoLikes;
private $url;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $webp;
/**
* @ORM\Column(type="string", length=500, nullable=true)
*/
private $previewUrl;
/**
* @ORM\Column(type="string", length=45, nullable=true)
*/
private $ip;
public function __construct()
{
$this->setActif(0);
$this->setUploaded(0);
$this->setViews(0);
$this->setVideo(null);
$this->setEmbed(1);
$this->setSlug('1');
$this->created_at = new \DateTimeImmutable();
$this->updated_at = new \DateTime();
$this->comments = new ArrayCollection();
$this->photoLikes = 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 getEmbed(): ?string
{
return $this->embed;
}
public function setEmbed(string $embed): self
{
$this->embed = $embed;
return $this;
}
public function getActif(): ?bool
{
return $this->actif;
}
public function setActif(bool $actif): self
{
$this->actif = $actif;
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 getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getVideo(): ?string
{
return $this->video;
}
public function setVideo(File $file = null)
{
$this->video = $file;
return $this;
}
public function getViews(): ?int
{
return $this->views;
}
public function setViews(int $views): self
{
$this->views = $views;
return $this;
}
public function getUploaded(): ?bool
{
return $this->uploaded;
}
public function setUploaded(bool $uploaded): self
{
$this->uploaded = $uploaded;
return $this;
}
public function getFilecode(): ?string
{
return $this->filecode;
}
public function setFilecode(string $filecode): self
{
$this->filecode = $filecode;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(string $url): self
{
$this->url = $url;
return $this;
}
/**
* @return Collection<int, PhotoLike>
*/
public function getNbPhotoLikes(): int
{
return sizeof($this->getPhotoLikes());
}
/**
* @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->setVideo($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->getVideo() === $this) {
$comment->setVideo(null);
}
}
return $this;
}
/**
* @return Collection<int, PhotoLike>
*/
public function getPhotoLikes(): Collection
{
return $this->photoLikes;
}
public function addPhotoLike(PhotoLike $photoLike): self
{
if (!$this->photoLikes->contains($photoLike)) {
$this->photoLikes[] = $photoLike;
$photoLike->setVideo($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->getVideo() === $this) {
$photoLike->setVideo(null);
}
}
return $this;
}
public function getWebp(): ?string
{
return $this->webp;
}
public function setWebp(?string $webp): self
{
$this->webp = $webp;
return $this;
}
public function getPreviewUrl(): ?string
{
return $this->previewUrl;
}
public function setPreviewUrl(?string $previewUrl): self
{
$this->previewUrl = $previewUrl;
return $this;
}
public function getIp(): ?string
{
return $this->ip;
}
public function setIp(?string $ip): self
{
$this->ip = $ip;
return $this;
}
}