src/Entity/Employee.php line 24

  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use App\Entity\enums\EmployeeJob;
  5. use App\Entity\enums\FamilySituation;
  6. use Symfony\Component\Uid\Ulid;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use App\Repository\EmployeeRepository;
  9. use Doctrine\Common\Collections\Collection;
  10. use ApiPlatform\Core\Annotation\ApiResource;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
  14. use Gedmo\Mapping\Annotation as Gedmo;
  15. #[ORM\Entity(repositoryClassEmployeeRepository::class)]
  16. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  17. #[ORM\HasLifecycleCallbacks()]
  18. #[ApiResource(
  19.     attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
  20. )]
  21. class Employee
  22. {
  23.     use Timestamps;
  24.     #[ORM\Id]
  25.     #[ORM\Column(type'ulid'uniquetrue)]
  26.     #[ORM\GeneratedValue(strategy"CUSTOM")]
  27.     #[ORM\CustomIdGenerator(class: UlidGenerator::class)]
  28.     #[Groups(['read:employee:basic'])]
  29.     private ?Ulid $id null;
  30.     #[ORM\Column(type'string'length255)]
  31.     #[Groups(['read:employee:basic'])]
  32.     private $first_name;
  33.     #[ORM\Column(type'string'length255)]
  34.     #[Groups(['read:employee:basic'])]
  35.     private $last_name;
  36.     #[ORM\Column(type'string'length255nullabletrue)]
  37.     #[Groups(['read:employee:basic'])]
  38.     private $email;
  39.     #[ORM\Column(type'string'length255nullabletrue)]
  40.     #[Groups(['read:employee:basic'])]
  41.     private $phone;
  42.     #[ORM\Column(type'string'length255nullabletrue)]
  43.     #[Groups(['read:employee:basic'])]
  44.     private $mobile;
  45.     #[ORM\Column(type'string'length255enumTypeEmployeeJob::class)]
  46.     #[Groups(['read:employee:basic'])]
  47.     private $job;
  48.     #[ORM\Column(type'text'nullabletrue)]
  49.     private $description;
  50.     #[ORM\Column(type'float')]
  51.     private $salary 0;
  52.     #[ORM\Column(type'date')]
  53.     #[Groups(['read:employee:basic'])]
  54.     private $birth_date;
  55.     #[ORM\Column(type'date')]
  56.     #[Groups(['read:employee:basic'])]
  57.     private $start_date;
  58.     #[ORM\Column(type'string'length255nullabletrue)]
  59.     #[Groups(['read:employee:basic'])]
  60.     private $number_social_security;
  61.     #[ORM\Column(type'string'length255enumTypeFamilySituation::class)]
  62.     private $family_situation;
  63.     #[ORM\Column(type'string'length255nullabletrue)]
  64.     #[Groups(['read:employee:basic'])]
  65.     private $photo;
  66.     #[ORM\Column(type'string'length255nullabletrue)]
  67.     private $curiculum;
  68.     #[ORM\OneToMany(mappedBy'employee'targetEntityCardid::class, orphanRemovaltruecascade: ['persist''remove'])]
  69.     private $identity;
  70.     #[ORM\OneToOne(inversedBy'employee'targetEntityLocation::class, cascade: ['persist''remove'])]
  71.     private $address;
  72.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'employees')]
  73.     #[ORM\JoinColumn(nullablefalse)]
  74.     private $owner;
  75.     #[ORM\ManyToMany(targetEntityClassroom::class, mappedBy'teachers')]
  76.     private $classrooms;
  77.     #[ORM\ManyToMany(targetEntityEvenement::class, mappedBy'employees')]
  78.     private $evenements;
  79.     #[ORM\ManyToMany(targetEntityTask::class, mappedBy'employees')]
  80.     private $tasks;
  81.     #[ORM\OneToMany(mappedBy'employee'targetEntityAbsenceEmployee::class, orphanRemovaltrue)]
  82.     private $absenceEmployees;
  83.     #[ORM\Column(type'string'length255nullabletrue)]
  84.     #[Groups(['read:employee:basic'])]
  85.     private $birth_place;
  86.     #[ORM\ManyToOne(targetEntitySeason::class, inversedBy'employees')]
  87.     #[ORM\JoinColumn(nullablefalse)]
  88.     private $season;
  89.     #[ORM\Column(length255nullabletrue)]
  90.     private ?string $registration_number;
  91.     public function __construct()
  92.     {
  93.         $this->identity = new ArrayCollection();
  94.         $this->start_date = new DateTime();
  95.         $this->birth_date = new DateTime();
  96.         $this->classrooms = new ArrayCollection();
  97.         $this->evenements = new ArrayCollection();
  98.         $this->tasks = new ArrayCollection();
  99.         $this->absenceEmployees = new ArrayCollection();
  100.         $this->family_situation FamilySituation::CELIBATAIRE;
  101.     }
  102.     public function __toString()
  103.     {
  104.         return $this->first_name " " $this->last_name;
  105.         ;
  106.     }
  107.     public function getId(): ?Ulid
  108.     {
  109.         return $this->id;
  110.     }
  111.     public function getFirstName(): ?string
  112.     {
  113.         return $this->first_name;
  114.     }
  115.     public function setFirstName(string $first_name): self
  116.     {
  117.         $this->first_name $first_name;
  118.         return $this;
  119.     }
  120.     public function getLastName(): ?string
  121.     {
  122.         return $this->last_name;
  123.     }
  124.     public function setLastName(string $last_name): self
  125.     {
  126.         $this->last_name $last_name;
  127.         return $this;
  128.     }
  129.     public function getEmail(): ?string
  130.     {
  131.         return $this->email;
  132.     }
  133.     public function setEmail(?string $email): self
  134.     {
  135.         $this->email $email;
  136.         return $this;
  137.     }
  138.     public function getPhone(): ?string
  139.     {
  140.         return $this->phone;
  141.     }
  142.     public function setPhone(?string $phone): self
  143.     {
  144.         $this->phone $phone;
  145.         return $this;
  146.     }
  147.     public function getMobile(): ?string
  148.     {
  149.         return $this->mobile;
  150.     }
  151.     public function setMobile(?string $mobile): self
  152.     {
  153.         $this->mobile $mobile;
  154.         return $this;
  155.     }
  156.     public function getJob(): ?EmployeeJob
  157.     {
  158.         return $this->job;
  159.     }
  160.     public function setJob(?EmployeeJob $job): self
  161.     {
  162.         $this->job $job;
  163.         return $this;
  164.     }
  165.     public function getDescription(): ?string
  166.     {
  167.         return $this->description;
  168.     }
  169.     public function setDescription(?string $description): self
  170.     {
  171.         $this->description $description;
  172.         return $this;
  173.     }
  174.     public function getSalary(): ?float
  175.     {
  176.         return $this->salary;
  177.     }
  178.     public function setSalary(float $salary): self
  179.     {
  180.         $this->salary $salary;
  181.         return $this;
  182.     }
  183.     public function getBirthDate(): ?\DateTimeInterface
  184.     {
  185.         return $this->birth_date;
  186.     }
  187.     public function setBirthDate(\DateTimeInterface $birth_date): self
  188.     {
  189.         $this->birth_date $birth_date;
  190.         return $this;
  191.     }
  192.     public function getStartDate(): ?\DateTimeInterface
  193.     {
  194.         return $this->start_date;
  195.     }
  196.     public function setStartDate(\DateTimeInterface $start_date): self
  197.     {
  198.         $this->start_date $start_date;
  199.         return $this;
  200.     }
  201.     public function getNumberSocialSecurity(): ?string
  202.     {
  203.         return $this->number_social_security;
  204.     }
  205.     public function setNumberSocialSecurity(?string $number_social_security): self
  206.     {
  207.         $this->number_social_security $number_social_security;
  208.         return $this;
  209.     }
  210.     public function getFamilySituation(): ?FamilySituation
  211.     {
  212.         return $this->family_situation;
  213.     }
  214.     public function setFamilySituation(FamilySituation $family_situation): self
  215.     {
  216.         $this->family_situation $family_situation;
  217.         return $this;
  218.     }
  219.     public function getPhoto(): ?string
  220.     {
  221.         return $this->photo;
  222.     }
  223.     public function setPhoto(?string $photo): self
  224.     {
  225.         $this->photo $photo;
  226.         return $this;
  227.     }
  228.     public function getCuriculum(): ?string
  229.     {
  230.         return $this->curiculum;
  231.     }
  232.     public function setCuriculum(?string $curiculum): self
  233.     {
  234.         $this->curiculum $curiculum;
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return Collection<int, Cardid>
  239.      */
  240.     public function getIdentity(): Collection
  241.     {
  242.         return $this->identity;
  243.     }
  244.     public function addIdentity(Cardid $identity): self
  245.     {
  246.         if (!$this->identity->contains($identity)) {
  247.             $this->identity[] = $identity;
  248.             $identity->setEmployee($this);
  249.         }
  250.         return $this;
  251.     }
  252.     public function removeIdentity(Cardid $identity): self
  253.     {
  254.         if ($this->identity->removeElement($identity)) {
  255.             // set the owning side to null (unless already changed)
  256.             if ($identity->getEmployee() === $this) {
  257.                 $identity->setEmployee(null);
  258.             }
  259.         }
  260.         return $this;
  261.     }
  262.     public function getAddress(): ?Location
  263.     {
  264.         return $this->address;
  265.     }
  266.     public function setAddress(?Location $address): self
  267.     {
  268.         $this->address $address;
  269.         return $this;
  270.     }
  271.     public function getOwner(): ?Company
  272.     {
  273.         return $this->owner;
  274.     }
  275.     public function setOwner(?Company $owner): self
  276.     {
  277.         $this->owner $owner;
  278.         return $this;
  279.     }
  280.     /**
  281.      * @return Collection<int, Classroom>
  282.      */
  283.     public function getClassrooms(): Collection
  284.     {
  285.         return $this->classrooms;
  286.     }
  287.     public function addClassroom(Classroom $classroom): self
  288.     {
  289.         if (!$this->classrooms->contains($classroom)) {
  290.             $this->classrooms[] = $classroom;
  291.             $classroom->addTeacher($this);
  292.         }
  293.         return $this;
  294.     }
  295.     public function removeClassroom(Classroom $classroom): self
  296.     {
  297.         if ($this->classrooms->removeElement($classroom)) {
  298.             $classroom->removeTeacher($this);
  299.         }
  300.         return $this;
  301.     }
  302.     /**
  303.      * @return Collection<int, Evenement>
  304.      */
  305.     public function getEvenements(): Collection
  306.     {
  307.         return $this->evenements;
  308.     }
  309.     public function addEvenement(Evenement $evenement): self
  310.     {
  311.         if (!$this->evenements->contains($evenement)) {
  312.             $this->evenements[] = $evenement;
  313.             $evenement->addEmployee($this);
  314.         }
  315.         return $this;
  316.     }
  317.     public function removeEvenement(Evenement $evenement): self
  318.     {
  319.         if ($this->evenements->removeElement($evenement)) {
  320.             $evenement->removeEmployee($this);
  321.         }
  322.         return $this;
  323.     }
  324.     /**
  325.      * @return Collection<int, Task>
  326.      */
  327.     public function getTasks(): Collection
  328.     {
  329.         return $this->tasks;
  330.     }
  331.     public function addTask(Task $task): self
  332.     {
  333.         if (!$this->tasks->contains($task)) {
  334.             $this->tasks[] = $task;
  335.             $task->addEmployee($this);
  336.         }
  337.         return $this;
  338.     }
  339.     public function removeTask(Task $task): self
  340.     {
  341.         if ($this->tasks->removeElement($task)) {
  342.             $task->removeEmployee($this);
  343.         }
  344.         return $this;
  345.     }
  346.     /**
  347.      * @return Collection<int, AbsenceEmployee>
  348.      */
  349.     public function getAbsenceEmployees(): Collection
  350.     {
  351.         return $this->absenceEmployees;
  352.     }
  353.     public function addAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
  354.     {
  355.         if (!$this->absenceEmployees->contains($absenceEmployee)) {
  356.             $this->absenceEmployees[] = $absenceEmployee;
  357.             $absenceEmployee->setEmployee($this);
  358.         }
  359.         return $this;
  360.     }
  361.     public function removeAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
  362.     {
  363.         if ($this->absenceEmployees->removeElement($absenceEmployee)) {
  364.             // set the owning side to null (unless already changed)
  365.             if ($absenceEmployee->getEmployee() === $this) {
  366.                 $absenceEmployee->setEmployee(null);
  367.             }
  368.         }
  369.         return $this;
  370.     }
  371.     public function getBirthPlace(): ?string
  372.     {
  373.         return $this->birth_place;
  374.     }
  375.     public function setBirthPlace(?string $birth_place): self
  376.     {
  377.         $this->birth_place $birth_place;
  378.         return $this;
  379.     }
  380.     public function getSeason(): ?Season
  381.     {
  382.         return $this->season;
  383.     }
  384.     public function setSeason(?Season $season): self
  385.     {
  386.         $this->season $season;
  387.         return $this;
  388.     }
  389.     public function getRegistrationNumber(): ?string
  390.     {
  391.         return $this->registration_number;
  392.     }
  393.     public function setRegistrationNumber(string $registration_number): static
  394.     {
  395.         $this->registration_number $registration_number;
  396.         return $this;
  397.     }
  398. }