<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\WorkersRepository;
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;
#[ApiFilter(SearchFilter::class, properties: [
'fullName' => 'ipartial',
'codeIpn' => 'exact',
'phone' => 'exact',
'code1c' => 'exact',
'email' => 'exact',
'accountWorkers.account.user.id' => 'exact',
'accountWorkers.account.id' => 'exact',
'accountWorkers.account.name' => 'ipartial',
'manager.id' => 'exact',
'manager.firstName' => 'ipartial',
'phone' => 'exact',
])]
#[ORM\Entity(repositoryClass: WorkersRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['worker:read']],
denormalizationContext: ['groups' => ['worker:write']],
order: ['id' => 'DESC'],
)]
class Workers
{
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read', 'job_woker:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read', 'job_woker:read'])]
#[ORM\Column(length: 255)]
private ?string $fullName = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEntered = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read'])]
#[ORM\Column(length: 100, nullable: true, options: ["default" => ""])]
private ?string $code1c = '';
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read'])]
#[ORM\Column(length: 100, nullable: true, unique: true)]
private ?string $codeIpn = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read'])]
#[ORM\Column(length: 50, nullable: true)]
private ?string $phone = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read'])]
#[ORM\Column(length: 50, nullable: true)]
private ?string $email = null;
#[ORM\OneToMany(mappedBy: 'worker', targetEntity: AccountWorker::class)]
private Collection $accountWorkers;
#[ORM\OneToMany(mappedBy: 'worker', targetEntity: JobWorker::class)]
private Collection $jobWorkers;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read'])]
#[ORM\ManyToOne(inversedBy: 'workers')]
private ?MediaObject $photo = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateStart = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEnd = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read', 'job_woker:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $position = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read', 'job_woker:read'])]
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateOfBirth = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read', 'job_woker:read'])]
#[ORM\Column(length: 10, nullable: true)]
private ?string $seriaPasport = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read', 'job_woker:read'])]
#[ORM\Column(length: 10, nullable: true)]
private ?string $numberPasport = null;
#[Groups(['worker:read', 'worker:write', 'account_worker:read', 'account_worker:write', 'account:read', 'read', 'account:write', 'write', 'job:read'])]
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
private ?MediaObject $userImage = null;
public function __construct()
{
$this->accountWorkers = new ArrayCollection();
$this->jobWorkers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFullName(): ?string
{
return $this->fullName;
}
public function setFullName(string $fullName): self
{
$this->fullName = $fullName;
return $this;
}
public function getDateEntered(): ?\DateTimeInterface
{
return $this->dateEntered;
}
public function setDateEntered(?\DateTimeInterface $dateEntered): self
{
$this->dateEntered = $dateEntered;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCode1c(): ?string
{
return $this->code1c;
}
public function setCode1c(?string $code1c): self
{
$this->code1c = $code1c;
return $this;
}
public function getCodeIpn(): ?string
{
return $this->codeIpn;
}
public function setCodeIpn(?string $codeIpn): self
{
$this->codeIpn = $codeIpn;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
/**
* @return Collection<int, AccountWorker>
*/
public function getAccountWorkers(): Collection
{
return $this->accountWorkers;
}
public function addAccountWorker(AccountWorker $accountWorker): self
{
if (!$this->accountWorkers->contains($accountWorker)) {
$this->accountWorkers->add($accountWorker);
$accountWorker->setWorker($this);
}
return $this;
}
public function removeAccountWorker(AccountWorker $accountWorker): self
{
if ($this->accountWorkers->removeElement($accountWorker)) {
// set the owning side to null (unless already changed)
if ($accountWorker->getWorker() === $this) {
$accountWorker->setWorker(null);
}
}
return $this;
}
/**
* @return Collection<int, JobWorker>
*/
public function getJobWorkers(): Collection
{
return $this->jobWorkers;
}
public function addJobWorker(JobWorker $jobWorker): self
{
if (!$this->jobWorkers->contains($jobWorker)) {
$this->jobWorkers->add($jobWorker);
$jobWorker->setWorker($this);
}
return $this;
}
public function removeJobWorker(JobWorker $jobWorker): self
{
if ($this->jobWorkers->removeElement($jobWorker)) {
// set the owning side to null (unless already changed)
if ($jobWorker->getWorker() === $this) {
$jobWorker->setWorker(null);
}
}
return $this;
}
public function getPhoto(): ?MediaObject
{
return $this->photo;
}
public function setPhoto(?MediaObject $photo): self
{
$this->photo = $photo;
return $this;
}
public function getDateStart(): ?\DateTimeInterface
{
return $this->dateStart;
}
public function setDateStart(?\DateTimeInterface $dateStart): self
{
$this->dateStart = $dateStart;
return $this;
}
public function getDateEnd(): ?\DateTimeInterface
{
return $this->dateEnd;
}
public function setDateEnd(?\DateTimeInterface $dateEnd): self
{
$this->dateEnd = $dateEnd;
return $this;
}
public function getPosition(): ?string
{
return $this->position;
}
public function setPosition(string $position): self
{
$this->position = $position;
return $this;
}
public function getdateOfBirth(): ?\DateTimeInterface
{
return $this->dateOfBirth;
}
public function setdateOfBirth(?\DateTimeInterface $dateOfBirth): self
{
$this->dateOfBirth = $dateOfBirth;
return $this;
}
public function getSeriaPasport(): ?string
{
return $this->seriaPasport;
}
public function setSeriaPasport(?string $seriaPasport): self
{
$this->seriaPasport = $seriaPasport;
return $this;
}
public function getNumberPasport(): ?string
{
return $this->numberPasport;
}
public function setNumberPasport(?string $numberPasport): self
{
$this->numberPasport = $numberPasport;
return $this;
}
public function getUserImage(): ?MediaObject
{
return $this->userImage;
}
public function setUserImage(?MediaObject $userImage): self
{
$this->userImage = $userImage;
return $this;
}
}