<?php
namespace App\Entity;
use App\Repository\PersonalRepository;
use App\Trait\Person;
use App\Trait\PersonPhysical;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: PersonalRepository::class)]
class Personal
{
use TimestampableEntity;
use Person;
use PersonPhysical;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 64, nullable: true)]
private ?string $job;
#[Assert\Positive]
#[ORM\Column(type: 'decimal', precision: 8, scale: 3, nullable: true)]
private ?string $salary;
#[ORM\ManyToOne(targetEntity: Agency::class)]
private ?Agency $affectedAgency;
#[ORM\ManyToMany(targetEntity: Agency::class, inversedBy: 'authPersonals')]
private $authAgencies;
#[ORM\OneToOne(mappedBy: 'personal', targetEntity: User::class, cascade: ['persist', 'remove'])]
private ?User $user;
#[ORM\ManyToOne(targetEntity: Profile::class)]
private ?Profile $profile;
public function __construct()
{
$this->authAgencies = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getJob(): ?string
{
return $this->job;
}
public function setJob(?string $job): self
{
$this->job = $job;
return $this;
}
public function getSalary(): ?string
{
return $this->salary;
}
public function setSalary(?string $salary): self
{
$this->salary = $salary;
return $this;
}
public function getAffectedAgency(): ?Agency
{
return $this->affectedAgency;
}
public function setAffectedAgency(?Agency $affectedAgency): self
{
$this->affectedAgency = $affectedAgency;
return $this;
}
/**
* @return Collection<int, Agency>
*/
public function getAuthAgencies(): Collection
{
return $this->authAgencies;
}
public function addAuthAgency(Agency $authAgency): self
{
if (!$this->authAgencies->contains($authAgency)) {
$this->authAgencies[] = $authAgency;
}
return $this;
}
public function removeAuthAgency(Agency $authAgency): self
{
$this->authAgencies->removeElement($authAgency);
return $this;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function getProfile(): ?Profile
{
return $this->profile;
}
public function setProfile(?Profile $profile): self
{
$this->profile = $profile;
return $this;
}
}