src/Entity/Client.php line 15
<?php
namespace App\Entity;
use App\Repository\ClientRepository;
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: ClientRepository::class)]
#[Vich\Uploadable]
class Client
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $firstname = null;
#[ORM\Column(length: 255)]
private ?string $email = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $enterprise = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $phone = null;
#[ORM\OneToMany(mappedBy: 'client', targetEntity: Program::class, cascade: ['remove'])]
private Collection $programs;
#[ORM\ManyToOne(inversedBy: 'clients')]
private ?User $adminUser = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image = null;
#[Vich\UploadableField(mapping: 'clients_images', fileNameProperty: 'image')]
private ?File $imageFile = null;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\OneToOne()]
private ?User $userClient = null;
/**
* @return \DateTimeImmutable|null
*/
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
/**
* @param \DateTimeImmutable|null $createdAt
*/
public function setCreatedAt(?\DateTimeImmutable $createdAt): void
{
$this->createdAt = $createdAt;
}
public function __construct()
{
$this->programs = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable();
}
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 getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getEnterprise(): ?string
{
return $this->enterprise;
}
public function setEnterprise(string $enterprise): self
{
$this->enterprise = $enterprise;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
/**
* @return Collection<int, Program>
*/
public function getPrograms(): Collection
{
return $this->programs;
}
public function addProgram(Program $program): self
{
if (!$this->programs->contains($program)) {
$this->programs->add($program);
$program->setClient($this);
}
return $this;
}
public function removeProgram(Program $program): self
{
if ($this->programs->removeElement($program)) {
// set the owning side to null (unless already changed)
if ($program->getClient() === $this) {
$program->setClient(null);
}
}
return $this;
}
public function getAdminUser(): ?User
{
return $this->adminUser;
}
public function setAdminUser(?User $adminUser): self
{
$this->adminUser = $adminUser;
return $this;
}
/**
* 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 'CandidateFile' as the bundle will inject one here
* during Doctrine hydration.
*
* @param CandidateFile|\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;
}
public function __toString(): string
{
return $this->enterprise;
}
public function getUserClient(): ?User
{
return $this->userClient;
}
public function setUserClient(?User $userClient): self
{
$this->userClient = $userClient;
return $this;
}
}