src/Entity/Employee.php line 24
<?php
namespace App\Entity;
use DateTime;
use App\Entity\enums\EmployeeJob;
use App\Entity\enums\FamilySituation;
use Symfony\Component\Uid\Ulid;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\EmployeeRepository;
use Doctrine\Common\Collections\Collection;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: EmployeeRepository::class)]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
#[ORM\HasLifecycleCallbacks()]
#[ApiResource(
attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
)]
class Employee
{
use Timestamps;
#[ORM\Id]
#[ORM\Column(type: 'ulid', unique: true)]
#[ORM\GeneratedValue(strategy: "CUSTOM")]
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
#[Groups(['read:employee:basic'])]
private ?Ulid $id = null;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['read:employee:basic'])]
private $first_name;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['read:employee:basic'])]
private $last_name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:employee:basic'])]
private $email;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:employee:basic'])]
private $phone;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:employee:basic'])]
private $mobile;
#[ORM\Column(type: 'string', length: 255, enumType: EmployeeJob::class)]
#[Groups(['read:employee:basic'])]
private $job;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\Column(type: 'float')]
private $salary = 0;
#[ORM\Column(type: 'date')]
#[Groups(['read:employee:basic'])]
private $birth_date;
#[ORM\Column(type: 'date')]
#[Groups(['read:employee:basic'])]
private $start_date;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:employee:basic'])]
private $number_social_security;
#[ORM\Column(type: 'string', length: 255, enumType: FamilySituation::class)]
private $family_situation;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:employee:basic'])]
private $photo;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $curiculum;
#[ORM\OneToMany(mappedBy: 'employee', targetEntity: Cardid::class, orphanRemoval: true, cascade: ['persist', 'remove'])]
private $identity;
#[ORM\OneToOne(inversedBy: 'employee', targetEntity: Location::class, cascade: ['persist', 'remove'])]
private $address;
#[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'employees')]
#[ORM\JoinColumn(nullable: false)]
private $owner;
#[ORM\ManyToMany(targetEntity: Classroom::class, mappedBy: 'teachers')]
private $classrooms;
#[ORM\ManyToMany(targetEntity: Evenement::class, mappedBy: 'employees')]
private $evenements;
#[ORM\ManyToMany(targetEntity: Task::class, mappedBy: 'employees')]
private $tasks;
#[ORM\OneToMany(mappedBy: 'employee', targetEntity: AbsenceEmployee::class, orphanRemoval: true)]
private $absenceEmployees;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:employee:basic'])]
private $birth_place;
#[ORM\ManyToOne(targetEntity: Season::class, inversedBy: 'employees')]
#[ORM\JoinColumn(nullable: false)]
private $season;
#[ORM\Column(length: 255, nullable: true)]
private ?string $registration_number;
public function __construct()
{
$this->identity = new ArrayCollection();
$this->start_date = new DateTime();
$this->birth_date = new DateTime();
$this->classrooms = new ArrayCollection();
$this->evenements = new ArrayCollection();
$this->tasks = new ArrayCollection();
$this->absenceEmployees = new ArrayCollection();
$this->family_situation = FamilySituation::CELIBATAIRE;
}
public function __toString()
{
return $this->first_name . " " . $this->last_name;
;
}
public function getId(): ?Ulid
{
return $this->id;
}
public function getFirstName(): ?string
{
return $this->first_name;
}
public function setFirstName(string $first_name): self
{
$this->first_name = $first_name;
return $this;
}
public function getLastName(): ?string
{
return $this->last_name;
}
public function setLastName(string $last_name): self
{
$this->last_name = $last_name;
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 = $phone;
return $this;
}
public function getMobile(): ?string
{
return $this->mobile;
}
public function setMobile(?string $mobile): self
{
$this->mobile = $mobile;
return $this;
}
public function getJob(): ?EmployeeJob
{
return $this->job;
}
public function setJob(?EmployeeJob $job): self
{
$this->job = $job;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getSalary(): ?float
{
return $this->salary;
}
public function setSalary(float $salary): self
{
$this->salary = $salary;
return $this;
}
public function getBirthDate(): ?\DateTimeInterface
{
return $this->birth_date;
}
public function setBirthDate(\DateTimeInterface $birth_date): self
{
$this->birth_date = $birth_date;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->start_date;
}
public function setStartDate(\DateTimeInterface $start_date): self
{
$this->start_date = $start_date;
return $this;
}
public function getNumberSocialSecurity(): ?string
{
return $this->number_social_security;
}
public function setNumberSocialSecurity(?string $number_social_security): self
{
$this->number_social_security = $number_social_security;
return $this;
}
public function getFamilySituation(): ?FamilySituation
{
return $this->family_situation;
}
public function setFamilySituation(FamilySituation $family_situation): self
{
$this->family_situation = $family_situation;
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
public function getCuriculum(): ?string
{
return $this->curiculum;
}
public function setCuriculum(?string $curiculum): self
{
$this->curiculum = $curiculum;
return $this;
}
/**
* @return Collection<int, Cardid>
*/
public function getIdentity(): Collection
{
return $this->identity;
}
public function addIdentity(Cardid $identity): self
{
if (!$this->identity->contains($identity)) {
$this->identity[] = $identity;
$identity->setEmployee($this);
}
return $this;
}
public function removeIdentity(Cardid $identity): self
{
if ($this->identity->removeElement($identity)) {
// set the owning side to null (unless already changed)
if ($identity->getEmployee() === $this) {
$identity->setEmployee(null);
}
}
return $this;
}
public function getAddress(): ?Location
{
return $this->address;
}
public function setAddress(?Location $address): self
{
$this->address = $address;
return $this;
}
public function getOwner(): ?Company
{
return $this->owner;
}
public function setOwner(?Company $owner): self
{
$this->owner = $owner;
return $this;
}
/**
* @return Collection<int, Classroom>
*/
public function getClassrooms(): Collection
{
return $this->classrooms;
}
public function addClassroom(Classroom $classroom): self
{
if (!$this->classrooms->contains($classroom)) {
$this->classrooms[] = $classroom;
$classroom->addTeacher($this);
}
return $this;
}
public function removeClassroom(Classroom $classroom): self
{
if ($this->classrooms->removeElement($classroom)) {
$classroom->removeTeacher($this);
}
return $this;
}
/**
* @return Collection<int, Evenement>
*/
public function getEvenements(): Collection
{
return $this->evenements;
}
public function addEvenement(Evenement $evenement): self
{
if (!$this->evenements->contains($evenement)) {
$this->evenements[] = $evenement;
$evenement->addEmployee($this);
}
return $this;
}
public function removeEvenement(Evenement $evenement): self
{
if ($this->evenements->removeElement($evenement)) {
$evenement->removeEmployee($this);
}
return $this;
}
/**
* @return Collection<int, Task>
*/
public function getTasks(): Collection
{
return $this->tasks;
}
public function addTask(Task $task): self
{
if (!$this->tasks->contains($task)) {
$this->tasks[] = $task;
$task->addEmployee($this);
}
return $this;
}
public function removeTask(Task $task): self
{
if ($this->tasks->removeElement($task)) {
$task->removeEmployee($this);
}
return $this;
}
/**
* @return Collection<int, AbsenceEmployee>
*/
public function getAbsenceEmployees(): Collection
{
return $this->absenceEmployees;
}
public function addAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
{
if (!$this->absenceEmployees->contains($absenceEmployee)) {
$this->absenceEmployees[] = $absenceEmployee;
$absenceEmployee->setEmployee($this);
}
return $this;
}
public function removeAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
{
if ($this->absenceEmployees->removeElement($absenceEmployee)) {
// set the owning side to null (unless already changed)
if ($absenceEmployee->getEmployee() === $this) {
$absenceEmployee->setEmployee(null);
}
}
return $this;
}
public function getBirthPlace(): ?string
{
return $this->birth_place;
}
public function setBirthPlace(?string $birth_place): self
{
$this->birth_place = $birth_place;
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): self
{
$this->season = $season;
return $this;
}
public function getRegistrationNumber(): ?string
{
return $this->registration_number;
}
public function setRegistrationNumber(string $registration_number): static
{
$this->registration_number = $registration_number;
return $this;
}
}