<?php
namespace App\Entity;
use App\Repository\AdministrationSectorRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=AdministrationSectorRepository::class)
* @ORM\HasLifecycleCallbacks()
* @Vich\Uploadable
*/
class AdministrationSector
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=50)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $description;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\OneToMany(targetEntity=AdministrationMove::class, mappedBy="administrationSector")
*/
private $moveId;
/**
* @ORM\Column(type="boolean")
*/
private $isCredit;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="sector_image", fileNameProperty="image")
*
* @var File|null
*/
private $imageFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
public function __construct()
{
$this->moveId = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAt(): self
{
$this->createdAt = new \DateTime();
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAt(): self
{
$this->updatedAt = new \DateTime();
return $this;
}
/**
* @return Collection|AdministrationMove[]
*/
public function getMoveId(): Collection
{
return $this->moveId;
}
public function addMoveId(AdministrationMove $moveId): self
{
if (!$this->moveId->contains($moveId)) {
$this->moveId[] = $moveId;
$moveId->setAdministrationSector($this);
}
return $this;
}
public function removeMoveId(AdministrationMove $moveId): self
{
if ($this->moveId->removeElement($moveId)) {
// set the owning side to null (unless already changed)
if ($moveId->getAdministrationSector() === $this) {
$moveId->setAdministrationSector(null);
}
}
return $this;
}
public function getIsCreditString(): ?string
{
if ($this->isCredit) {
return 1;
} else {
return 0;
}
}
public function getIsCredit(): ?bool
{
return $this->isCredit;
}
public function setIsCredit(bool $isCredit): self
{
$this->isCredit = $isCredit;
return $this;
}
public function __toString()
{
return $this->name;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
*/
public function setImageFile(?File $imageFile = null): void
{
$this->imageFile = $imageFile;
if (null !== $imageFile) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
}