src/Entity/Organization.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\EntityTrait\Listable;
  4. use App\Repository\OrganizationRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. /**
  12.  * @ORM\Entity(repositoryClass=OrganizationRepository::class)
  13.  * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="id", columns={"id"})})
  14.  * @Vich\Uploadable
  15.  */
  16. class Organization
  17. {
  18.     use Listable;
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\Column(type="integer")
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private ?int $id null;
  25.     /**
  26.      * @ORM\Column(type="string", nullable=true)
  27.      */
  28.     private ?string $address null;
  29.     /**
  30.      * @ORM\Column(type="string", nullable=true)
  31.      */
  32.     private ?string $postalCode null;
  33.     /**
  34.      * @ORM\Column(type="string", nullable=true)
  35.      */
  36.     private ?string $city null;
  37.     /**
  38.      * @ORM\Column(type="string", nullable=true)
  39.      */
  40.     private ?string $country null;
  41.     /**
  42.      * @ORM\Column(type="string", nullable=true)
  43.      */
  44.     private ?string $telephoneNumber null;
  45.     /**
  46.      * @ORM\Column(type="string", nullable=true)
  47.      */
  48.     private ?string $email null;
  49.     /**
  50.      * @ORM\Column(type="decimal", nullable=true, precision=3, scale=2)
  51.      * @Assert\GreaterThan(0)
  52.      * @Assert\LessThan(9.99)
  53.      */
  54.     private ?float $defaultElectricityCostPerUnit null;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity="App\Entity\Project", mappedBy="organization")
  57.      */
  58.     private Collection $projects;
  59.     /**
  60.      * @ORM\Column(type="string", length=255, nullable=true)
  61.      *
  62.      * @var string
  63.      */
  64.     private $logo;
  65.     /**
  66.      * @Vich\UploadableField(mapping="logos", fileNameProperty="logo")
  67.      *
  68.      * @var File
  69.      */
  70.     private $logoFile;
  71.     /**
  72.      * @ORM\Column(type="datetime", nullable=true) \DateTime
  73.      *
  74.      * @var \Datetime
  75.      */
  76.     private $updatedAt;
  77.     public function __construct()
  78.     {
  79.         $this->projects = new ArrayCollection();
  80.         $this->updatedAt = new \DateTime();
  81.     }
  82.     public function getId(): ?int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function getAddress(): ?string
  87.     {
  88.         return $this->address;
  89.     }
  90.     public function setAddress(?string $address): self
  91.     {
  92.         $this->address $address;
  93.         return $this;
  94.     }
  95.     public function getPostalCode(): ?string
  96.     {
  97.         return $this->postalCode;
  98.     }
  99.     public function setPostalCode(?string $postalCode): self
  100.     {
  101.         $this->postalCode $postalCode;
  102.         return $this;
  103.     }
  104.     public function getCity(): ?string
  105.     {
  106.         return $this->city;
  107.     }
  108.     public function setCity(?string $city): self
  109.     {
  110.         $this->city $city;
  111.         return $this;
  112.     }
  113.     public function getCountry(): ?string
  114.     {
  115.         return $this->country;
  116.     }
  117.     public function setCountry(?string $country): self
  118.     {
  119.         $this->country $country;
  120.         return $this;
  121.     }
  122.     public function getTelephoneNumber(): ?string
  123.     {
  124.         return $this->telephoneNumber;
  125.     }
  126.     public function setTelephoneNumber(?string $telephoneNumber): self
  127.     {
  128.         $this->telephoneNumber $telephoneNumber;
  129.         return $this;
  130.     }
  131.     public function getEmail(): ?string
  132.     {
  133.         return $this->email;
  134.     }
  135.     public function setEmail(?string $email): self
  136.     {
  137.         $this->email $email;
  138.         return $this;
  139.     }
  140.     public function getLastEntry(): ?int
  141.     {
  142.         return $this->lastEntry;
  143.     }
  144.     public function setLastEntry(?int $lastEntry): self
  145.     {
  146.         $this->lastEntry $lastEntry;
  147.         return $this;
  148.     }
  149.     public function getLastEntryDateTime(): ?\DateTimeInterface
  150.     {
  151.         return $this->lastEntryDateTime;
  152.     }
  153.     public function setLastEntryDateTime(?\DateTimeInterface $lastEntryDateTime): self
  154.     {
  155.         $this->lastEntryDateTime $lastEntryDateTime;
  156.         return $this;
  157.     }
  158.     public function getDefaultElectricityCostPerUnit(): ?string
  159.     {
  160.         return $this->defaultElectricityCostPerUnit;
  161.     }
  162.     public function setDefaultElectricityCostPerUnit(?string $defaultElectricityCostPerUnit): self
  163.     {
  164.         $this->defaultElectricityCostPerUnit $defaultElectricityCostPerUnit;
  165.         return $this;
  166.     }
  167.     /**
  168.      * @return Collection|Project[]
  169.      */
  170.     public function getProjects(): Collection
  171.     {
  172.         return $this->projects;
  173.     }
  174.     public function addProject(Project $project): self
  175.     {
  176.         if (!$this->projects->contains($project)) {
  177.             $this->projects[] = $project;
  178.             $project->setOrganization($this);
  179.         }
  180.         return $this;
  181.     }
  182.     public function removeProject(Project $project): self
  183.     {
  184.         if ($this->projects->removeElement($project)) {
  185.             // set the owning side to null (unless already changed)
  186.             if ($project->getOrganization() === $this) {
  187.                 $project->setOrganization(null);
  188.             }
  189.         }
  190.         return $this;
  191.     }
  192.     public function setlogoFile(File $logo null)
  193.     {
  194.         $this->logoFile $logo;
  195.         // VERY IMPORTANT:
  196.         // It is required that at least one field changes if you are using Doctrine,
  197.         // otherwise the event listeners won't be called and the file is lost
  198.         if ($logo) {
  199.             // if 'updatedAt' is not defined in your entity, use another property
  200.             $this->updatedAt = new \DateTime('now');
  201.         }
  202.     }
  203.     public function getlogoFile()
  204.     {
  205.         return $this->logoFile;
  206.     }
  207.     public function setlogo($logo)
  208.     {
  209.         $this->logo $logo;
  210.     }
  211.     public function getlogo()
  212.     {
  213.         return $this->logo;
  214.     }
  215.     public function getUpdatedAt(): ?\DateTimeInterface
  216.     {
  217.         return $this->updatedAt;
  218.     }
  219.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  220.     {
  221.         $this->updatedAt $updatedAt;
  222.         return $this;
  223.     }
  224. }