<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\AppPersonalAccountRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use ApiPlatform\Core\Annotation\ApiProperty;
#[ORM\Entity(repositoryClass: AppPersonalAccountRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['personalAcc:read']],
denormalizationContext: ['groups' => ['personalAcc:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(SearchFilter::class, properties: [
// 'name' => 'ipartial',
'owner.id' => 'exact',
'number' => 'exact',
'parent.id' => 'exact',
'main' => 'exact',
// 'manager.id' => 'exact',
// 'manager.firstName' => 'ipartial',
// 'phone' => 'exact',
])]
class AppPersonalAccount
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['personalAcc:read', 'personalAcc:write', 'user:read'])]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'appPersonalAccounts')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['personalAcc:read'])]
private ?User $owner = null;
#[ORM\Column(length: 100)]
#[Groups(['personalAcc:read', 'user:read'])]
private ?string $number = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['personalAcc:read', 'personalAcc:write', 'user:read'])]
private ?string $name = null;
#[ORM\Column(nullable: true)]
#[Groups(['personalAcc:read', 'user:read'])]
private ?int $numberOfScale = null;
#[ORM\Column(nullable: true)]
#[Groups(['personalAcc:read', 'user:read'])]
private ?bool $active = null;
#[ORM\OneToMany(mappedBy: 'personal', targetEntity: AppCounterReading::class, cascade:['persist', 'remove'])]
#[Groups(['personalAcc:read', 'user:read'])]
private Collection $appCounterReadings;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['personalAcc:read', 'user:read'])]
private ?string $fullAddress = null;
#[ORM\Column(length: 100, nullable: true)]
#[Groups(['personalAcc:read', 'user:read'])]
private ?string $city = null;
#[ORM\Column(length: 100, nullable: true)]
#[Groups(['personalAcc:read', 'user:read'])]
private ?string $street = null;
#[ORM\Column(length: 100, nullable: true)]
#[Groups(['personalAcc:read', 'user:read'])]
private ?string $building = null;
#[ORM\Column(length: 100, nullable: true)]
#[Groups(['personalAcc:read', 'user:read'])]
private ?string $room = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['personalAcc:read', 'user:read'])]
private ?string $mainFullAddress = null;
#[Groups(['personalAcc:read'])]
#[ORM\ManyToOne(inversedBy: 'appPersonalAccounts')]
private ?Accounts $accounts = null;
#[ORM\OneToMany(mappedBy: 'personalAccount', targetEntity: ServiceOrderHistory::class, cascade:['persist'])]
private Collection $serviceOrderHistories;
#[Groups(['personalAcc:read', 'user:read'])]
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'appPersonalAccounts')]
private ?self $parent = null;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class, cascade:['remove'])]
private Collection $appPersonalAccounts;
#[Groups(['personalAcc:read', 'user:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $type = null;
#[Groups(['personalAcc:read', 'user:read'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEntered = null;
#[Groups(['personalAcc:read', 'user:read'])]
#[ORM\Column(nullable: true)]
private ?bool $isMain = null;
#[Groups(['personalAcc:read', 'user:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $eic = null;
#[Groups(['personalAcc:read', 'user:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $counter = null;
#[Groups(['personalAcc:read', 'personalAcc:write', 'user:read'])]
#[ORM\Column(nullable: true)]
private ?bool $isShow = null;
public function __construct()
{
$this->appCounterReadings = new ArrayCollection();
$this->serviceOrderHistories = new ArrayCollection();
$this->appPersonalAccounts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): static
{
$this->owner = $owner;
return $this;
}
public function getNumber(): ?string
{
return $this->number;
}
public function setNumber(string $number): static
{
$this->number = $number;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getNumberOfScale(): ?int
{
return $this->numberOfScale;
}
public function setNumberOfScale(?int $numberOfScale): static
{
$this->numberOfScale = $numberOfScale;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(?bool $active): static
{
$this->active = $active;
return $this;
}
/**
* @return Collection<int, AppCounterReading>
*/
public function getAppCounterReadings(): Collection
{
return $this->appCounterReadings;
}
public function addAppCounterReading(AppCounterReading $appCounterReading): static
{
if (!$this->appCounterReadings->contains($appCounterReading)) {
$this->appCounterReadings->add($appCounterReading);
$appCounterReading->setPersonal($this);
}
return $this;
}
public function removeAppCounterReading(AppCounterReading $appCounterReading): static
{
if ($this->appCounterReadings->removeElement($appCounterReading)) {
// set the owning side to null (unless already changed)
if ($appCounterReading->getPersonal() === $this) {
$appCounterReading->setPersonal(null);
}
}
return $this;
}
public function getFullAddress(): ?string
{
return $this->fullAddress;
}
public function setFullAddress(?string $fullAddress): static
{
$this->fullAddress = $fullAddress;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): static
{
$this->city = $city;
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): static
{
$this->street = $street;
return $this;
}
public function getBuilding(): ?string
{
return $this->building;
}
public function setBuilding(?string $building): static
{
$this->building = $building;
return $this;
}
public function getRoom(): ?string
{
return $this->room;
}
public function setRoom(?string $room): static
{
$this->room = $room;
return $this;
}
public function getMainFullAddress(): ?string
{
return $this->mainFullAddress;
}
public function setMainFullAddress(string $mainFullAddress): static
{
$this->mainFullAddress = $mainFullAddress;
return $this;
}
public function getAccounts(): ?Accounts
{
return $this->accounts;
}
public function setAccounts(?Accounts $accounts): static
{
$this->accounts = $accounts;
return $this;
}
/**
* @return Collection<int, ServiceOrderHistory>
*/
public function getServiceOrderHistories(): Collection
{
return $this->serviceOrderHistories;
}
public function addServiceOrderHistory(ServiceOrderHistory $serviceOrderHistory): static
{
if (!$this->serviceOrderHistories->contains($serviceOrderHistory)) {
$this->serviceOrderHistories->add($serviceOrderHistory);
$serviceOrderHistory->setPersonalAccount($this);
}
return $this;
}
public function removeServiceOrderHistory(ServiceOrderHistory $serviceOrderHistory): static
{
if ($this->serviceOrderHistories->removeElement($serviceOrderHistory)) {
// set the owning side to null (unless already changed)
if ($serviceOrderHistory->getPersonalAccount() === $this) {
$serviceOrderHistory->setPersonalAccount(null);
}
}
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): static
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getAppPersonalAccounts(): Collection
{
return $this->appPersonalAccounts;
}
public function addAppPersonalAccount(self $appPersonalAccount): static
{
if (!$this->appPersonalAccounts->contains($appPersonalAccount)) {
$this->appPersonalAccounts->add($appPersonalAccount);
$appPersonalAccount->setParent($this);
}
return $this;
}
public function removeAppPersonalAccount(self $appPersonalAccount): static
{
if ($this->appPersonalAccounts->removeElement($appPersonalAccount)) {
// set the owning side to null (unless already changed)
if ($appPersonalAccount->getParent() === $this) {
$appPersonalAccount->setParent(null);
}
}
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
public function getDateEntered(): ?\DateTimeInterface
{
return $this->dateEntered;
}
public function setDateEntered(?\DateTimeInterface $dateEntered): static
{
$this->dateEntered = $dateEntered;
return $this;
}
public function isIsMain(): ?bool
{
return $this->isMain;
}
public function setIsMain(?bool $isMain): static
{
$this->isMain = $isMain;
return $this;
}
public function getEic(): ?string
{
return $this->eic;
}
public function setEic(?string $eic): static
{
$this->eic = $eic;
return $this;
}
public function getCounter(): ?string
{
return $this->counter;
}
public function setCounter(?string $counter): static
{
$this->counter = $counter;
return $this;
}
public function isIsShow(): ?bool
{
return $this->isShow;
}
public function setIsShow(?bool $isShow): static
{
$this->isShow = $isShow;
return $this;
}
}