<?php
namespace App\Entity;
use App\EntityTrait\Listable;
use App\Repository\OrganizationRepository;
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;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=OrganizationRepository::class)
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="id", columns={"id"})})
* @Vich\Uploadable
*/
class Organization
{
use Listable;
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $address = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $postalCode = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $city = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $country = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $telephoneNumber = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $email = null;
/**
* @ORM\Column(type="decimal", nullable=true, precision=3, scale=2)
* @Assert\GreaterThan(0)
* @Assert\LessThan(9.99)
*/
private ?float $defaultElectricityCostPerUnit = null;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Project", mappedBy="organization")
*/
private Collection $projects;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
private $logo;
/**
* @Vich\UploadableField(mapping="logos", fileNameProperty="logo")
*
* @var File
*/
private $logoFile;
/**
* @ORM\Column(type="datetime", nullable=true) \DateTime
*
* @var \Datetime
*/
private $updatedAt;
public function __construct()
{
$this->projects = new ArrayCollection();
$this->updatedAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postalCode;
}
public function setPostalCode(?string $postalCode): self
{
$this->postalCode = $postalCode;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function getTelephoneNumber(): ?string
{
return $this->telephoneNumber;
}
public function setTelephoneNumber(?string $telephoneNumber): self
{
$this->telephoneNumber = $telephoneNumber;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getLastEntry(): ?int
{
return $this->lastEntry;
}
public function setLastEntry(?int $lastEntry): self
{
$this->lastEntry = $lastEntry;
return $this;
}
public function getLastEntryDateTime(): ?\DateTimeInterface
{
return $this->lastEntryDateTime;
}
public function setLastEntryDateTime(?\DateTimeInterface $lastEntryDateTime): self
{
$this->lastEntryDateTime = $lastEntryDateTime;
return $this;
}
public function getDefaultElectricityCostPerUnit(): ?string
{
return $this->defaultElectricityCostPerUnit;
}
public function setDefaultElectricityCostPerUnit(?string $defaultElectricityCostPerUnit): self
{
$this->defaultElectricityCostPerUnit = $defaultElectricityCostPerUnit;
return $this;
}
/**
* @return Collection|Project[]
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Project $project): self
{
if (!$this->projects->contains($project)) {
$this->projects[] = $project;
$project->setOrganization($this);
}
return $this;
}
public function removeProject(Project $project): self
{
if ($this->projects->removeElement($project)) {
// set the owning side to null (unless already changed)
if ($project->getOrganization() === $this) {
$project->setOrganization(null);
}
}
return $this;
}
public function setlogoFile(File $logo = null)
{
$this->logoFile = $logo;
// VERY IMPORTANT:
// 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
if ($logo) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}
public function getlogoFile()
{
return $this->logoFile;
}
public function setlogo($logo)
{
$this->logo = $logo;
}
public function getlogo()
{
return $this->logo;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
}