src/Entity/Client.php line 42
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\Post;use App\Controller\Api\Client\ApiClientInvoicesController;use App\Kimia;use App\Model\Wallet\WalletInterface;use App\Repository\ClientRepository;use App\Service\GeoIP;use App\Trait\ActivableTrait;use App\Trait\ArrayableTrait;use App\Trait\DateTrait;use App\Trait\DeletableTrait;use App\Trait\WalletTrait;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: ClientRepository::class)]#[ApiResource(operations: [new GetCollection(normalizationContext: ['groups' => ['client:list']]),new Get(),new Post(uriTemplate: "/clients/invoices",controller: ApiClientInvoicesController::class,normalizationContext: ['groups' => ['client:list', 'client:invoices']],denormalizationContext: ['groups' => ['client:invoices:get']],write: false,)],normalizationContext: ['groups' => ['client:list', 'client:view']])]class Client implements WalletInterface{use ArrayableTrait;use DateTrait {__construct as private constructDate;}use ActivableTrait;use DeletableTrait;use WalletTrait;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['client:list', 'client:invoices', 'attendance:list'])]private ?int $id = null;#[ORM\Column(length: 255)]#[Groups(['client:list', 'order:list', 'attendance:list'])]private ?string $firstname = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['client:list', 'order:list', 'attendance:list'])]private ?string $lastname = null;#[ORM\Column(length: 180, nullable: true)]#[Groups(['client:list', 'order:view', 'attendance:list'])]private ?string $email = null;#[ORM\Column(length: 15, nullable: true)]#[Groups(['client:list', 'order:view', 'attendance:list'])]private ?string $phone = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['client:list', 'order:view'])]private ?string $comment = null;#[ORM\ManyToOne(inversedBy: 'clients')]#[ORM\JoinColumn(nullable: true)]private ?Department $department = null;#[ORM\ManyToOne(inversedBy: 'clients')]#[ORM\JoinColumn(nullable: false)]private ?Establishment $establishment = null;#[ORM\ManyToMany(targetEntity: Order::class, mappedBy: 'clients')]private Collection $orders;#[ORM\Column]private ?int $quota = 0;#[ORM\Column(options: ['default' => true])]private ?bool $isTaxable = true;#[ORM\Column(length: 255, nullable: true)]#[Groups(['client:invoices:get'])]private ?string $ref = null;#[ORM\OneToMany(mappedBy: 'client', targetEntity: Invoice::class)]#[Groups(['client:invoices'])]private Collection $invoices;#[ORM\ManyToOne(cascade: ["persist"])]#[ORM\JoinColumn(nullable: true)]private ?Attachment $thumbnail = null;#[ORM\Column(length: 2, nullable: true)]private ?string $country;#[ORM\Column(length: 255, nullable: true)]private ?string $name = null;#[ORM\OneToMany(mappedBy: 'client', targetEntity: Address::class, cascade: ['persist'])]private Collection $addresses;#[ORM\OneToMany(mappedBy: 'client', targetEntity: Document::class, cascade: ['persist'])]private Collection $documents;#[ORM\OneToMany(mappedBy: 'client', targetEntity: Mutuality::class)]private Collection $mutualities;#[ORM\OneToMany(mappedBy: 'client', targetEntity: Attendance::class)]private Collection $attendances;#[ORM\OneToMany(mappedBy: 'client', targetEntity: Card::class)]private Collection $cards;#[ORM\Column(length: 255, nullable: true)]private ?string $city = null;public function __construct(){$this->constructDate();$this->isActive = Kimia::ACTIVE;$this->orders = new ArrayCollection();$this->invoices = new ArrayCollection();$this->addresses = new ArrayCollection();$this->country = 'CD';$this->documents = new ArrayCollection();$this->mutualities = new ArrayCollection();$this->attendances = new ArrayCollection();$this->cards = new ArrayCollection();$this->ordersList = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getFullname(): ?string{return "$this->firstname $this->lastname";}public function getFirstname(): ?string{return $this->firstname;}public function setFirstname(string $firstname): self{$this->firstname = $firstname;return $this;}public function getLastname(): ?string{return $this->lastname;}public function setLastname(?string $lastname): self{$this->lastname = $lastname;return $this;}public function getEmail(): ?string{return $this->email;}public function setEmail(?string $email): self{$this->email = $email;return $this;}public function getPhone(): ?string{return $this->phone;}public function setPhone(?string $phone): self{$this->phone = GeoIP::phoneResolve($phone, $this->country);return $this;}public function getComment(): ?string{return $this->comment;}public function setComment(?string $comment): self{$this->comment = $comment;return $this;}public function __toString(): string{return $this->getName() ?? $this->getEmail() ?? $this->getPhone() ?? "";}public function getDepartment(): ?Department{return $this->department;}public function setDepartment(?Department $department): self{$this->department = $department;return $this;}public function getEstablishment(): ?Establishment{return $this->establishment;}public function setEstablishment(?Establishment $establishment): self{$this->establishment = $establishment;return $this;}public function getQuota(): ?int{return $this->quota;}public function setQuota(int $quota): self{$this->quota = $quota;return $this;}public function incrementQuota(int $quota = 1): self{$this->quota += $quota;return $this;}public function decrementQuota(): void{$this->quota = $this->getQuota() - 1;}public function isIsTaxable(): ?bool{return $this->isTaxable;}public function setIsTaxable(bool $isTaxable): self{$this->isTaxable = $isTaxable;return $this;}public function getRef(): ?string{return $this->ref;}public function setRef(?string $ref): static{$this->ref = $ref;return $this;}/*** @return Collection<int, Invoice>*/public function getInvoices(): Collection{return $this->invoices;}public function addInvoice(Invoice $invoice): static{if (!$this->invoices->contains($invoice)) {$this->invoices->add($invoice);$invoice->setClient($this);}return $this;}public function removeInvoice(Invoice $invoice): static{if ($this->invoices->removeElement($invoice)) {// set the owning side to null (unless already changed)if ($invoice->getClient() === $this) {$invoice->setClient(null);}}return $this;}public function getThumbnail(): ?Attachment{return $this->thumbnail;}public function setThumbnail(?Attachment $thumbnail): self{$this->thumbnail = $thumbnail;return $this;}public function getCountry(): ?string{return $this->country;}public function setCountry(?string $country): static{$this->country = $country;return $this;}public function getName(): ?string{return $this->name;}public function setName(?string $name): static{$this->name = $name;return $this;}/*** @return Collection<int, Address>*/public function getAddresses(): Collection{return $this->addresses;}public function addAddress(Address $address): static{if (!$this->addresses->contains($address)) {$this->addresses->add($address);$address->setClient($this);}return $this;}public function removeAddress(Address $address): static{if ($this->addresses->removeElement($address)) {// set the owning side to null (unless already changed)if ($address->getClient() === $this) {$address->setClient(null);}}return $this;}/*** @return Collection<int, Document>*/public function getDocuments(): Collection{return $this->documents;}public function addDocument(Document $document): static{if (!$this->documents->contains($document)) {$this->documents->add($document);$document->setClient($this);}return $this;}public function removeDocument(Document $document): static{if ($this->documents->removeElement($document)) {// set the owning side to null (unless already changed)if ($document->getClient() === $this) {$document->setClient(null);}}return $this;}/*** @return Collection<int, Mutuality>*/public function getMutualities(): Collection{return $this->mutualities;}public function addMutuality(Mutuality $mutuality): static{if (!$this->mutualities->contains($mutuality)) {$this->mutualities->add($mutuality);$mutuality->setClient($this);}return $this;}public function removeMutuality(Mutuality $mutuality): static{if ($this->mutualities->removeElement($mutuality)) {// set the owning side to null (unless already changed)if ($mutuality->getClient() === $this) {$mutuality->setClient(null);}}return $this;}/*** @return Collection<int, Attendance>*/public function getAttendances(): Collection{return $this->attendances;}public function addAttendance(Attendance $attendance): static{if (!$this->attendances->contains($attendance)) {$this->attendances->add($attendance);$attendance->setClient($this);}return $this;}public function removeAttendance(Attendance $attendance): static{if ($this->attendances->removeElement($attendance)) {// set the owning side to null (unless already changed)if ($attendance->getClient() === $this) {$attendance->setClient(null);}}return $this;}/*** @return Collection<int, Card>*/public function getCards(): Collection{return $this->cards;}public function addCard(Card $card): static{if (!$this->cards->contains($card)) {$this->cards->add($card);$card->setClient($this);}return $this;}public function removeCard(Card $card): static{if ($this->cards->removeElement($card)) {// set the owning side to null (unless already changed)if ($card->getClient() === $this) {$card->setClient(null);}}return $this;}public function getCity(): ?string{return $this->city;}public function setCity(?string $city): static{$this->city = $city;return $this;}/*** @return Collection<int, Order>*/public function getOrders(): Collection{return $this->ordersList;}public function addOrders(Order $orders): static{if (!$this->ordersList->contains($orders)) {$this->ordersList->add($orders);$orders->addClient($this);}return $this;}public function removeOrders(Order $orders): static{if ($this->ordersList->removeElement($orders)) {$orders->removeClient($this);}return $this;}}