<?php
namespace App\Entity;
use App\Repository\RessourceRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: RessourceRepository::class)]
#[Vich\Uploadable]
class Ressource
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Vich\UploadableField(mapping: 'ressource', fileNameProperty: 'fileName')]
private ?File $file = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $fileName = null;
#[ORM\Column]
private ?\DateTimeImmutable $addedAt = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\Column]
private ?int $isActive = 1;
#[ORM\ManyToOne(inversedBy: 'ressource')]
private ?Project $project = null;
#[ORM\ManyToOne(inversedBy: 'ressources')]
private ?RessourceDirectory $directory = null;
public function __construct()
{
$this->setAddedAt(new \DateTimeImmutable());
}
public function getId(): ?int
{
return $this->id;
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileName(?string $fileName): self
{
$this->fileName = $fileName;
return $this;
}
public function getAddedAt(): ?\DateTimeImmutable
{
return $this->addedAt;
}
public function setAddedAt(\DateTimeImmutable $addedAt): self
{
$this->addedAt = $addedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getIsActive(): ?int
{
return $this->isActive;
}
public function setIsActive(int $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function setFile(?File $file = null): void
{
$this->file = $file;
if (null !== $file) {
$this->updatedAt = new \DateTimeImmutable('now');
}
}
public function getFile(): ?File
{
return $this->file;
}
public function getProject(): ?Project
{
return $this->project;
}
public function setProject(?Project $project): self
{
$this->project = $project;
return $this;
}
public function getDirectory(): ?RessourceDirectory
{
return $this->directory;
}
public function setDirectory(?RessourceDirectory $directory): self
{
$this->directory = $directory;
return $this;
}
}