src/Entity/Client.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClientRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. #[ORM\Entity(repositoryClassClientRepository::class)]
  10. #[Vich\Uploadable]
  11. class Client
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $name null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $firstname null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $email null;
  23.     #[ORM\Column(length255nullabletrue)]
  24.     private ?string $enterprise null;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?string $phone null;
  27.     #[ORM\OneToMany(mappedBy'client'targetEntityProgram::class, cascade: ['remove'])]
  28.     private Collection $programs;
  29.     #[ORM\ManyToOne(inversedBy'clients')]
  30.     private ?User $adminUser null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $image null;
  33.     #[Vich\UploadableField(mapping'clients_images'fileNameProperty'image')]
  34.     private ?File $imageFile null;
  35.     #[ORM\Column]
  36.     private ?\DateTimeImmutable $createdAt null;
  37.     #[ORM\OneToOne()]
  38.     private ?User $userClient null;
  39.     /**
  40.      * @return \DateTimeImmutable|null
  41.      */
  42.     public function getCreatedAt(): ?\DateTimeImmutable
  43.     {
  44.         return $this->createdAt;
  45.     }
  46.     /**
  47.      * @param \DateTimeImmutable|null $createdAt
  48.      */
  49.     public function setCreatedAt(?\DateTimeImmutable $createdAt): void
  50.     {
  51.         $this->createdAt $createdAt;
  52.     }
  53.     public function __construct()
  54.     {
  55.         $this->programs = new ArrayCollection();
  56.         $this->createdAt =  new \DateTimeImmutable();
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getName(): ?string
  63.     {
  64.         return $this->name;
  65.     }
  66.     public function setName(string $name): self
  67.     {
  68.         $this->name $name;
  69.         return $this;
  70.     }
  71.     public function getFirstname(): ?string
  72.     {
  73.         return $this->firstname;
  74.     }
  75.     public function setFirstname(string $firstname): self
  76.     {
  77.         $this->firstname $firstname;
  78.         return $this;
  79.     }
  80.     public function getEmail(): ?string
  81.     {
  82.         return $this->email;
  83.     }
  84.     public function setEmail(string $email): self
  85.     {
  86.         $this->email $email;
  87.         return $this;
  88.     }
  89.     public function getEnterprise(): ?string
  90.     {
  91.         return $this->enterprise;
  92.     }
  93.     public function setEnterprise(string $enterprise): self
  94.     {
  95.         $this->enterprise $enterprise;
  96.         return $this;
  97.     }
  98.     public function getPhone(): ?string
  99.     {
  100.         return $this->phone;
  101.     }
  102.     public function setPhone(string $phone): self
  103.     {
  104.         $this->phone $phone;
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, Program>
  109.      */
  110.     public function getPrograms(): Collection
  111.     {
  112.         return $this->programs;
  113.     }
  114.     public function addProgram(Program $program): self
  115.     {
  116.         if (!$this->programs->contains($program)) {
  117.             $this->programs->add($program);
  118.             $program->setClient($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeProgram(Program $program): self
  123.     {
  124.         if ($this->programs->removeElement($program)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($program->getClient() === $this) {
  127.                 $program->setClient(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132.     public function getAdminUser(): ?User
  133.     {
  134.         return $this->adminUser;
  135.     }
  136.     public function setAdminUser(?User $adminUser): self
  137.     {
  138.         $this->adminUser $adminUser;
  139.         return $this;
  140.     }
  141.     /**
  142.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  143.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  144.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  145.      * must be able to accept an instance of 'CandidateFile' as the bundle will inject one here
  146.      * during Doctrine hydration.
  147.      *
  148.      * @param CandidateFile|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  149.      */
  150.     public function setImageFile(?File $imageFile null): void
  151.     {
  152.         $this->imageFile $imageFile;
  153.         if (null !== $imageFile) {
  154.             // It is required that at least one field changes if you are using doctrine
  155.             // otherwise the event listeners won't be called and the file is lost
  156.             $this->updatedAt = new \DateTimeImmutable();
  157.         }
  158.     }
  159.     public function getImageFile(): ?File
  160.     {
  161.         return $this->imageFile;
  162.     }
  163.     public function getImage(): ?string
  164.     {
  165.         return $this->image;
  166.     }
  167.     public function setImage(?string $image): self
  168.     {
  169.         $this->image $image;
  170.         return $this;
  171.     }
  172.     public function  __toString(): string
  173.     {
  174.         return $this->enterprise;
  175.     }
  176.     public function getUserClient(): ?User
  177.     {
  178.         return $this->userClient;
  179.     }
  180.     public function setUserClient(?User $userClient): self
  181.     {
  182.         $this->userClient $userClient;
  183.         return $this;
  184.     }
  185. }