src/Entity/Season.php line 22

  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Symfony\Component\Uid\Ulid;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use App\Repository\SeasonRepository;
  9. use ApiPlatform\Core\Annotation\ApiResource;
  10. use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. #[ORM\Entity(repositoryClassSeasonRepository::class)]
  14. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  15. #[ORM\HasLifecycleCallbacks]
  16. #[ApiResource(
  17.     attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
  18. )]
  19. class Season
  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:season:basic')]
  27.     private ?Ulid $id null;
  28.     #[ORM\Column(type'string'length255)]
  29.     #[Groups('read:season:basic')]
  30.     private $name;
  31.     #[ORM\Column(type'string'length255nullabletrue)]
  32.     #[Groups('read:season:basic')]
  33.     private $description;
  34.     #[ORM\Column(type'datetime')]
  35.     #[Groups('read:season:basic')]
  36.     private $start_date;
  37.     #[ORM\Column(type'datetime')]
  38.     #[Groups('read:season:basic')]
  39.     private $end_date;
  40.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'seasons')]
  41.     #[ORM\JoinColumn(nullablefalse)]
  42.     private $owner;
  43.     #[ORM\Column(type'boolean')]
  44.     private $is_active false;
  45.     #[ORM\OneToMany(mappedBy'season'targetEntitySubscription::class, orphanRemovaltrue)]
  46.     private $subscriptions;
  47.     #[ORM\OneToMany(mappedBy'season'targetEntityClassroom::class, orphanRemovaltrue)]
  48.     private $classrooms;
  49.     #[ORM\OneToMany(mappedBy'season'targetEntityTask::class, orphanRemovaltrue)]
  50.     private $tasks;
  51.     #[ORM\OneToMany(mappedBy'season'targetEntityEvenement::class, orphanRemovaltrue)]
  52.     private $evenements;
  53.     #[ORM\OneToMany(mappedBy'season'targetEntityPayment::class, orphanRemovaltrue)]
  54.     private $payments;
  55.     #[ORM\OneToMany(mappedBy'season'targetEntityExpense::class, orphanRemovaltrue)]
  56.     private $expenses;
  57.     #[ORM\OneToMany(mappedBy'season'targetEntityAbsenceEmployee::class, orphanRemovaltrue)]
  58.     private $absenceEmployees;
  59.     #[ORM\OneToMany(mappedBy'season'targetEntityChild::class, orphanRemovaltrue)]
  60.     private $children;
  61.     #[ORM\OneToMany(mappedBy'season'targetEntityFamilyMember::class, orphanRemovaltrue)]
  62.     private $familyMembers;
  63.     #[ORM\OneToMany(mappedBy'season'targetEntityEmployee::class, orphanRemovaltrue)]
  64.     private $employees;
  65.     #[ORM\OneToMany(mappedBy'season'targetEntityPointing::class, orphanRemovaltrue)]
  66.     private $pointings;
  67.     function __construct()
  68.     {
  69.         $this->start_date = new DateTime();
  70.         $this->end_date = new DateTime();
  71.         $this->subscriptions = new ArrayCollection();
  72.         $this->classrooms = new ArrayCollection();
  73.         $this->tasks = new ArrayCollection();
  74.         $this->evenements = new ArrayCollection();
  75.         $this->payments = new ArrayCollection();
  76.         $this->expenses = new ArrayCollection();
  77.         $this->absenceChildren = new ArrayCollection();
  78.         $this->absenceEmployees = new ArrayCollection();
  79.         $this->children = new ArrayCollection();
  80.         $this->familyMembers = new ArrayCollection();
  81.         $this->employees = new ArrayCollection();
  82.         $this->pointings = new ArrayCollection();
  83.     }
  84.     public function __toString()
  85.     {
  86.         return $this->name;
  87.     }
  88.     public function getId(): ?Ulid
  89.     {
  90.         return $this->id;
  91.     }
  92.     public function getName(): ?string
  93.     {
  94.         return $this->name;
  95.     }
  96.     public function setName(string $name): self
  97.     {
  98.         $this->name $name;
  99.         return $this;
  100.     }
  101.     public function getDescription(): ?string
  102.     {
  103.         return $this->description;
  104.     }
  105.     public function setDescription(?string $description): self
  106.     {
  107.         $this->description $description;
  108.         return $this;
  109.     }
  110.     public function getStartDate(): ?\DateTimeInterface
  111.     {
  112.         return $this->start_date;
  113.     }
  114.     public function setStartDate(\DateTimeInterface $start_date): self
  115.     {
  116.         $this->start_date $start_date;
  117.         return $this;
  118.     }
  119.     public function getEndDate(): ?\DateTimeInterface
  120.     {
  121.         return $this->end_date;
  122.     }
  123.     public function setEndDate(\DateTimeInterface $end_date): self
  124.     {
  125.         $this->end_date $end_date;
  126.         return $this;
  127.     }
  128.     public function getOwner(): ?Company
  129.     {
  130.         return $this->owner;
  131.     }
  132.     public function setOwner(?Company $owner): self
  133.     {
  134.         $this->owner $owner;
  135.         return $this;
  136.     }
  137.     public function isIsActive(): ?bool
  138.     {
  139.         return $this->is_active;
  140.     }
  141.     public function setIsActive(bool $is_active): self
  142.     {
  143.         $this->is_active $is_active;
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return Collection<int, Subscription>
  148.      */
  149.     public function getSubscriptions(): Collection
  150.     {
  151.         return $this->subscriptions;
  152.     }
  153.     public function addSubscription(Subscription $subscription): self
  154.     {
  155.         if (!$this->subscriptions->contains($subscription)) {
  156.             $this->subscriptions[] = $subscription;
  157.             $subscription->setSeason($this);
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeSubscription(Subscription $subscription): self
  162.     {
  163.         if ($this->subscriptions->removeElement($subscription)) {
  164.             // set the owning side to null (unless already changed)
  165.             if ($subscription->getSeason() === $this) {
  166.                 $subscription->setSeason(null);
  167.             }
  168.         }
  169.         return $this;
  170.     }
  171.     /**
  172.      * @return Collection<int, Classroom>
  173.      */
  174.     public function getClassrooms(): Collection
  175.     {
  176.         return $this->classrooms;
  177.     }
  178.     public function addClassroom(Classroom $classroom): self
  179.     {
  180.         if (!$this->classrooms->contains($classroom)) {
  181.             $this->classrooms[] = $classroom;
  182.             $classroom->setSeason($this);
  183.         }
  184.         return $this;
  185.     }
  186.     public function removeClassroom(Classroom $classroom): self
  187.     {
  188.         if ($this->classrooms->removeElement($classroom)) {
  189.             // set the owning side to null (unless already changed)
  190.             if ($classroom->getSeason() === $this) {
  191.                 $classroom->setSeason(null);
  192.             }
  193.         }
  194.         return $this;
  195.     }
  196.     /**
  197.      * @return Collection<int, Task>
  198.      */
  199.     public function getTasks(): Collection
  200.     {
  201.         return $this->tasks;
  202.     }
  203.     public function addTask(Task $task): self
  204.     {
  205.         if (!$this->tasks->contains($task)) {
  206.             $this->tasks[] = $task;
  207.             $task->setSeason($this);
  208.         }
  209.         return $this;
  210.     }
  211.     public function removeTask(Task $task): self
  212.     {
  213.         if ($this->tasks->removeElement($task)) {
  214.             // set the owning side to null (unless already changed)
  215.             if ($task->getSeason() === $this) {
  216.                 $task->setSeason(null);
  217.             }
  218.         }
  219.         return $this;
  220.     }
  221.     /**
  222.      * @return Collection<int, Evenement>
  223.      */
  224.     public function getEvenements(): Collection
  225.     {
  226.         return $this->evenements;
  227.     }
  228.     public function addEvenement(Evenement $evenement): self
  229.     {
  230.         if (!$this->evenements->contains($evenement)) {
  231.             $this->evenements[] = $evenement;
  232.             $evenement->setSeason($this);
  233.         }
  234.         return $this;
  235.     }
  236.     public function removeEvenement(Evenement $evenement): self
  237.     {
  238.         if ($this->evenements->removeElement($evenement)) {
  239.             // set the owning side to null (unless already changed)
  240.             if ($evenement->getSeason() === $this) {
  241.                 $evenement->setSeason(null);
  242.             }
  243.         }
  244.         return $this;
  245.     }
  246.     /**
  247.      * @return Collection<int, Payment>
  248.      */
  249.     public function getPayments(): Collection
  250.     {
  251.         return $this->payments;
  252.     }
  253.     public function addPayment(Payment $payment): self
  254.     {
  255.         if (!$this->payments->contains($payment)) {
  256.             $this->payments[] = $payment;
  257.             $payment->setSeason($this);
  258.         }
  259.         return $this;
  260.     }
  261.     public function removePayment(Payment $payment): self
  262.     {
  263.         if ($this->payments->removeElement($payment)) {
  264.             // set the owning side to null (unless already changed)
  265.             if ($payment->getSeason() === $this) {
  266.                 $payment->setSeason(null);
  267.             }
  268.         }
  269.         return $this;
  270.     }
  271.     /**
  272.      * @return Collection<int, Expense>
  273.      */
  274.     public function getExpenses(): Collection
  275.     {
  276.         return $this->expenses;
  277.     }
  278.     public function addExpense(Expense $expense): self
  279.     {
  280.         if (!$this->expenses->contains($expense)) {
  281.             $this->expenses[] = $expense;
  282.             $expense->setSeason($this);
  283.         }
  284.         return $this;
  285.     }
  286.     public function removeExpense(Expense $expense): self
  287.     {
  288.         if ($this->expenses->removeElement($expense)) {
  289.             // set the owning side to null (unless already changed)
  290.             if ($expense->getSeason() === $this) {
  291.                 $expense->setSeason(null);
  292.             }
  293.         }
  294.         return $this;
  295.     }
  296.     /**
  297.      * @return Collection<int, AbsenceEmployee>
  298.      */
  299.     public function getAbsenceEmployees(): Collection
  300.     {
  301.         return $this->absenceEmployees;
  302.     }
  303.     public function addAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
  304.     {
  305.         if (!$this->absenceEmployees->contains($absenceEmployee)) {
  306.             $this->absenceEmployees[] = $absenceEmployee;
  307.             $absenceEmployee->setSeason($this);
  308.         }
  309.         return $this;
  310.     }
  311.     public function removeAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
  312.     {
  313.         if ($this->absenceEmployees->removeElement($absenceEmployee)) {
  314.             // set the owning side to null (unless already changed)
  315.             if ($absenceEmployee->getSeason() === $this) {
  316.                 $absenceEmployee->setSeason(null);
  317.             }
  318.         }
  319.         return $this;
  320.     }
  321.     /**
  322.      * @return Collection<int, Child>
  323.      */
  324.     public function getChildren(): Collection
  325.     {
  326.         return $this->children;
  327.     }
  328.     public function addChild(Child $child): self
  329.     {
  330.         if (!$this->children->contains($child)) {
  331.             $this->children[] = $child;
  332.             $child->setSeason($this);
  333.         }
  334.         return $this;
  335.     }
  336.     public function removeChild(Child $child): self
  337.     {
  338.         if ($this->children->removeElement($child)) {
  339.             // set the owning side to null (unless already changed)
  340.             if ($child->getSeason() === $this) {
  341.                 $child->setSeason(null);
  342.             }
  343.         }
  344.         return $this;
  345.     }
  346.     /**
  347.      * @return Collection<int, FamilyMember>
  348.      */
  349.     public function getFamilyMembers(): Collection
  350.     {
  351.         return $this->familyMembers;
  352.     }
  353.     public function addFamilyMember(FamilyMember $familyMember): self
  354.     {
  355.         if (!$this->familyMembers->contains($familyMember)) {
  356.             $this->familyMembers[] = $familyMember;
  357.             $familyMember->setSeason($this);
  358.         }
  359.         return $this;
  360.     }
  361.     public function removeFamilyMember(FamilyMember $familyMember): self
  362.     {
  363.         if ($this->familyMembers->removeElement($familyMember)) {
  364.             // set the owning side to null (unless already changed)
  365.             if ($familyMember->getSeason() === $this) {
  366.                 $familyMember->setSeason(null);
  367.             }
  368.         }
  369.         return $this;
  370.     }
  371.     /**
  372.      * @return Collection<int, Employee>
  373.      */
  374.     public function getEmployees(): Collection
  375.     {
  376.         return $this->employees;
  377.     }
  378.     public function addEmployee(Employee $employee): self
  379.     {
  380.         if (!$this->employees->contains($employee)) {
  381.             $this->employees[] = $employee;
  382.             $employee->setSeason($this);
  383.         }
  384.         return $this;
  385.     }
  386.     public function removeEmployee(Employee $employee): self
  387.     {
  388.         if ($this->employees->removeElement($employee)) {
  389.             // set the owning side to null (unless already changed)
  390.             if ($employee->getSeason() === $this) {
  391.                 $employee->setSeason(null);
  392.             }
  393.         }
  394.         return $this;
  395.     }
  396.     /**
  397.      * @return Collection<int, Pointing>
  398.      */
  399.     public function getPointings(): Collection
  400.     {
  401.         return $this->pointings;
  402.     }
  403.     public function addPointing(Pointing $pointing): self
  404.     {
  405.         if (!$this->pointings->contains($pointing)) {
  406.             $this->pointings[] = $pointing;
  407.             $pointing->setSeason($this);
  408.         }
  409.         return $this;
  410.     }
  411.     public function removePointing(Pointing $pointing): self
  412.     {
  413.         if ($this->pointings->removeElement($pointing)) {
  414.             // set the owning side to null (unless already changed)
  415.             if ($pointing->getSeason() === $this) {
  416.                 $pointing->setSeason(null);
  417.             }
  418.         }
  419.         return $this;
  420.     }
  421. }