src/Entity/AbsenceEmployee.php line 22

  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use App\Entity\Company;
  5. use App\Entity\Employee;
  6. use Symfony\Component\Uid\Ulid;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use ApiPlatform\Core\Annotation\ApiResource;
  9. use App\Repository\AbsenceEmployeeRepository;
  10. use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. #[ORM\Entity(repositoryClassAbsenceEmployeeRepository::class)]
  14. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  15. #[ORM\HasLifecycleCallbacks]
  16. #[ApiResource(
  17.     attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
  18. )]
  19. class AbsenceEmployee
  20. {
  21.     use Timestamps;
  22.     #[ORM\Id]
  23.     #[ORM\Column(type'ulid'uniquetrue)]
  24.     #[ORM\GeneratedValue(strategy"CUSTOM")]
  25.     #[ORM\CustomIdGenerator(class: UlidGenerator::class)]
  26.     #[Groups('read:absenceemployee:basic')]
  27.     private ?Ulid $id null;
  28.     #[ORM\Column(type'string'length255)]
  29.     private $name;
  30.     #[ORM\Column(type'text'nullabletrue)]
  31.     #[Groups('read:absenceemployee:basic')]
  32.     private $description;
  33.     #[ORM\Column(type'date')]
  34.     #[Groups('read:absenceemployee:basic')]
  35.     private $date;
  36.     #[ORM\Column(type'string'length255)]
  37.     #[Groups('read:absenceemployee:basic')]
  38.     private $duration 'un jours';
  39.     #[ORM\Column(type'string'length255nullabletrue)]
  40.     #[Groups('read:absenceemployee:basic')]
  41.     private $reason;
  42.     #[ORM\ManyToOne(targetEntityEmployee::class, inversedBy'absenceEmployees')]
  43.     #[ORM\JoinColumn(nullablefalse)]
  44.     private $employee;
  45.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'absenceEmployees')]
  46.     #[ORM\JoinColumn(nullablefalse)]
  47.     private $owner;
  48.     #[ORM\ManyToOne(targetEntitySeason::class, inversedBy'absenceEmployees')]
  49.     #[ORM\JoinColumn(nullablefalse)]
  50.     private $season;
  51.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'absenceEmployees')]
  52.     #[ORM\JoinColumn(nullablefalse)]
  53.     private $created_by;
  54.     public function __construct()
  55.     {
  56.         return $this->name ' ';
  57.         return $this->date = new DateTime();
  58.     }
  59.     public function getId(): ?Ulid
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getName(): ?string
  64.     {
  65.         return $this->name;
  66.     }
  67.     public function setName(string $name): self
  68.     {
  69.         $this->name $name;
  70.         return $this;
  71.     }
  72.     public function getDescription(): ?string
  73.     {
  74.         return $this->description;
  75.     }
  76.     public function setDescription(?string $description): self
  77.     {
  78.         $this->description $description;
  79.         return $this;
  80.     }
  81.     public function getDate(): ?\DateTimeInterface
  82.     {
  83.         return $this->date;
  84.     }
  85.     public function setDate(\DateTimeInterface $date): self
  86.     {
  87.         $this->date $date;
  88.         return $this;
  89.     }
  90.     public function getDuration(): ?string
  91.     {
  92.         return $this->duration;
  93.     }
  94.     public function setDuration(string $duration): self
  95.     {
  96.         $this->duration $duration;
  97.         return $this;
  98.     }
  99.     public function getReason(): ?string
  100.     {
  101.         return $this->reason;
  102.     }
  103.     public function setReason(?string $reason): self
  104.     {
  105.         $this->reason $reason;
  106.         return $this;
  107.     }
  108.     public function getEmployee(): ?Employee
  109.     {
  110.         return $this->employee;
  111.     }
  112.     public function setEmployee(?Employee $employee): self
  113.     {
  114.         $this->employee $employee;
  115.         return $this;
  116.     }
  117.     public function getOwner(): ?Company
  118.     {
  119.         return $this->owner;
  120.     }
  121.     public function setOwner(?Company $owner): self
  122.     {
  123.         $this->owner $owner;
  124.         return $this;
  125.     }
  126.     public function getSeason(): ?Season
  127.     {
  128.         return $this->season;
  129.     }
  130.     public function setSeason(?Season $season): self
  131.     {
  132.         $this->season $season;
  133.         return $this;
  134.     }
  135.     public function getCreatedBy(): ?User
  136.     {
  137.         return $this->created_by;
  138.     }
  139.     public function setCreatedBy(?User $created_by): self
  140.     {
  141.         $this->created_by $created_by;
  142.         return $this;
  143.     }
  144. }