src/Entity/Company.php line 42

  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use App\Entity\User;
  5. use App\Entity\Season;
  6. use App\Entity\Expense;
  7. use App\Entity\Location;
  8. use App\Entity\Classroom;
  9. use App\Entity\enums\CompanyCategory;
  10. use Symfony\Component\Uid\Ulid;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use App\Repository\CompanyRepository;
  13. use App\Controller\MyCompanyController;
  14. use Doctrine\Common\Collections\Collection;
  15. use ApiPlatform\Core\Annotation\ApiResource;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. use Symfony\Component\Serializer\Annotation\Groups;
  18. use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
  19. use Gedmo\Mapping\Annotation as Gedmo;
  20. #[ORM\Entity(repositoryClassCompanyRepository::class)]
  21. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  22. #[ORM\HasLifecycleCallbacks()]
  23. #[ApiResource(
  24.     normalizationContext: [
  25.         'groups' => ['read:company']
  26.     ],
  27.     itemOperations: [
  28.         'mycompany' => [
  29.             'pagination_enabled' => false,
  30.             'path' => '/mycompany',
  31.             'method' => 'get',
  32.             'requirements' => [],
  33.             'controller' => MyCompanyController::class,
  34.             'read' => false,
  35.         ]
  36.     ],
  37.     collectionOperations: [],
  38. )]
  39. class Company
  40. {
  41.     use Timestamps;
  42.     const TYPES = [
  43.         'Crèche',
  44.         'Jardin d\'enfants',
  45.         'Établissement Â« multi-accueil Â».'
  46.     ];
  47.     #[ORM\Id]
  48.     #[ORM\Column(type'ulid'uniquetrue)]
  49.     #[ORM\GeneratedValue(strategy"CUSTOM")]
  50.     #[ORM\CustomIdGenerator(class: UlidGenerator::class)]
  51.     #[Groups(['read:company'])]
  52.     private ?Ulid $id null;
  53.     #[ORM\Column(type'string'length255)]
  54.     #[Groups(['read:company'])]
  55.     private $name;
  56.     #[ORM\Column(type'string'length255enumTypeCompanyCategory::class)]
  57.     #[Groups(['read:company'])]
  58.     private $type;
  59.     #[ORM\Column(type'string'length255nullabletrue)]
  60.     #[Groups(['read:company'])]
  61.     private $size;
  62.     #[ORM\Column(type'string'length255nullabletrue)]
  63.     #[Groups(['read:company'])]
  64.     private $logo;
  65.     #[ORM\Column(type'string'length255nullabletrue)]
  66.     #[Groups(['read:company'])]
  67.     private $email;
  68.     #[ORM\Column(type'string'length255nullabletrue)]
  69.     #[Groups(['read:company'])]
  70.     private $phone;
  71.     #[ORM\Column(type'string'length255nullabletrue)]
  72.     #[Groups(['read:company'])]
  73.     private $mobile;
  74.     #[ORM\Column(type'string'length255nullabletrue)]
  75.     #[Groups(['read:company'])]
  76.     private $fax;
  77.     #[ORM\Column(type'text'nullabletrue)]
  78.     #[Groups(['read:company'])]
  79.     private $description;
  80.     #[ORM\Column(type'string'length255nullabletrue)]
  81.     #[Groups(['read:company'])]
  82.     private $website;
  83.     #[ORM\Column(type'string'length255nullabletrue)]
  84.     #[Groups(['read:company'])]
  85.     private $facebook;
  86.     #[ORM\Column(type'string'length255nullabletrue)]
  87.     #[Groups(['read:company'])]
  88.     private $twitter;
  89.     #[ORM\Column(type'string'length255nullabletrue)]
  90.     #[Groups(['read:company'])]
  91.     private $instagram;
  92.     #[ORM\Column(type'string'length255nullabletrue)]
  93.     #[Groups(['read:company'])]
  94.     private $youtube;
  95.     #[ORM\Column(type'string'length255nullabletrue)]
  96.     #[Groups(['read:company'])]
  97.     private $tiktok;
  98.     #[ORM\Column(type'string'length255nullabletrue)]
  99.     #[Groups(['read:company'])]
  100.     private $rc;
  101.     #[ORM\Column(type'string'length255nullabletrue)]
  102.     #[Groups(['read:company'])]
  103.     private $nif;
  104.     #[ORM\Column(type'string'length255nullabletrue)]
  105.     #[Groups(['read:company'])]
  106.     private $nis;
  107.     #[ORM\Column(type'boolean'nullabletrue)]
  108.     private $is_active;
  109.     #[ORM\OneToMany(mappedBy'company'targetEntityUser::class)]
  110.     private $users;
  111.     #[ORM\OneToOne(targetEntityLocation::class, cascade: ['persist''remove'])]
  112.     #[Groups(['read:company'])]
  113.     private $address;
  114.     #[ORM\Column(type'string'length255nullabletrue)]
  115.     private $date_format;
  116.     #[ORM\Column(type'string'length255nullabletrue)]
  117.     private $languege;
  118.     #[ORM\Column(type'string'length255nullabletrue)]
  119.     private $currencie;
  120.     #[ORM\Column(type'string'length255nullabletrue)]
  121.     private $time_zone;
  122.     #[ORM\OneToMany(mappedBy'owner'targetEntityExpense::class, orphanRemovaltrue)]
  123.     private $expenses;
  124.     #[ORM\OneToMany(mappedBy'owner'targetEntityExpenseCategory::class, orphanRemovaltrue)]
  125.     private $expenseCategories;
  126.     #[ORM\OneToMany(mappedBy'owner'targetEntitySeason::class, orphanRemovaltrue)]
  127.     private $seasons;
  128.     #[ORM\OneToMany(mappedBy'owner'targetEntityService::class, orphanRemovaltrue)]
  129.     private $services;
  130.     #[ORM\OneToMany(mappedBy'owner'targetEntitySection::class, orphanRemovaltrue)]
  131.     private $sections;
  132.     #[ORM\OneToMany(mappedBy'owner'targetEntityFamilyMember::class, orphanRemovaltrue)]
  133.     private $familyMembers;
  134.     #[ORM\OneToMany(mappedBy'owner'targetEntityChild::class, orphanRemovaltrue)]
  135.     private $children;
  136.     #[ORM\OneToMany(mappedBy'owner'targetEntityEmployee::class, orphanRemovaltrue)]
  137.     private $employees;
  138.     #[ORM\OneToMany(mappedBy'owner'targetEntitySubscription::class, orphanRemovaltrue)]
  139.     private $subscriptions;
  140.     #[ORM\OneToMany(mappedBy'owner'targetEntityPayment::class, orphanRemovaltrue)]
  141.     private $payments;
  142.     #[ORM\OneToMany(mappedBy'owner'targetEntityClassroom::class, orphanRemovaltrue)]
  143.     private $classrooms;
  144.     #[ORM\OneToMany(mappedBy'owner'targetEntityEvenement::class, orphanRemovaltrue)]
  145.     private $evenements;
  146.     #[ORM\OneToMany(mappedBy'owner'targetEntityTask::class, orphanRemovaltrue)]
  147.     private $tasks;
  148.     #[ORM\OneToMany(mappedBy'owner'targetEntityAbsenceEmployee::class, orphanRemovaltrue)]
  149.     private $absenceEmployees;
  150.     #[ORM\OneToMany(mappedBy'owner'targetEntityPost::class, orphanRemovaltrue)]
  151.     private $posts;
  152.     #[ORM\OneToMany(mappedBy'owner'targetEntityColleague::class, orphanRemovaltrue)]
  153.     private $colleagues;
  154.     #[ORM\OneToMany(mappedBy'owner'targetEntityAbonnement::class, orphanRemovaltrue)]
  155.     private $abonnements;
  156.     #[ORM\OneToMany(mappedBy'owner'targetEntityOrder::class, orphanRemovaltrue)]
  157.     private $orders;
  158.     #[ORM\OneToMany(mappedBy'owner'targetEntityPrechild::class, orphanRemovaltrue)]
  159.     private $prechildren;
  160.     #[ORM\OneToMany(mappedBy'owner'targetEntityPointing::class, orphanRemovaltrue)]
  161.     private $pointings;
  162.     #[ORM\OneToMany(mappedBy'owner'targetEntityActivity::class)]
  163.     private Collection $activities;
  164.     public function __construct()
  165.     {
  166.         $this->cars = new ArrayCollection();
  167.         $this->users = new ArrayCollection();
  168.         $this->type CompanyCategory::creche;
  169.         $this->expenses = new ArrayCollection();
  170.         $this->expenseCategories = new ArrayCollection();
  171.         $this->seasons = new ArrayCollection();
  172.         $this->services = new ArrayCollection();
  173.         $this->sections = new ArrayCollection();
  174.         $this->familyMembers = new ArrayCollection();
  175.         $this->children = new ArrayCollection();
  176.         $this->employees = new ArrayCollection();
  177.         $this->subscriptions = new ArrayCollection();
  178.         $this->payments = new ArrayCollection();
  179.         $this->classrooms = new ArrayCollection();
  180.         $this->evenements = new ArrayCollection();
  181.         $this->tasks = new ArrayCollection();
  182.         $this->absenceChildren = new ArrayCollection();
  183.         $this->absenceEmployees = new ArrayCollection();
  184.         $this->posts = new ArrayCollection();
  185.         $this->colleagues = new ArrayCollection();
  186.         $this->abonnements = new ArrayCollection();
  187.         $this->orders = new ArrayCollection();
  188.         $this->prechildren = new ArrayCollection();
  189.         $this->currencie 'DZD';
  190.         $this->pointings = new ArrayCollection();
  191.         $this->activities = new ArrayCollection();
  192.     }
  193.     public function __toString()
  194.     {
  195.         return $this->name;
  196.     }
  197.     public function isTrial()
  198.     {
  199.         $now = new DateTime();
  200.         $interval $now->diff($this->getCreatedAt(), true);
  201.         if (intval($interval->format('%a')) < 30) {
  202.             return true;
  203.         }
  204.         return false;
  205.     }
  206.     public function hasActivePlan()
  207.     {
  208.         $abonnements $this->getAbonnements();
  209.         if (count($abonnements) > 0) {
  210.             return true;
  211.         }
  212.         return false;
  213.     }
  214.     public function getId(): ?Ulid
  215.     {
  216.         return $this->id;
  217.     }
  218.     public function getName(): ?string
  219.     {
  220.         return $this->name;
  221.     }
  222.     public function setName(string $name): self
  223.     {
  224.         $this->name $name;
  225.         return $this;
  226.     }
  227.     public function getLogo(): ?string
  228.     {
  229.         return $this->logo;
  230.     }
  231.     public function setLogo(?string $logo): self
  232.     {
  233.         $this->logo $logo;
  234.         return $this;
  235.     }
  236.     public function getEmail(): ?string
  237.     {
  238.         return $this->email;
  239.     }
  240.     public function setEmail(?string $email): self
  241.     {
  242.         $this->email $email;
  243.         return $this;
  244.     }
  245.     public function getPhone(): ?string
  246.     {
  247.         return $this->phone;
  248.     }
  249.     public function setPhone(?string $phone): self
  250.     {
  251.         $this->phone $phone;
  252.         return $this;
  253.     }
  254.     public function getMobile(): ?string
  255.     {
  256.         return $this->mobile;
  257.     }
  258.     public function setMobile(?string $mobile): self
  259.     {
  260.         $this->mobile $mobile;
  261.         return $this;
  262.     }
  263.     public function getFax(): ?string
  264.     {
  265.         return $this->fax;
  266.     }
  267.     public function setFax(?string $fax): self
  268.     {
  269.         $this->fax $fax;
  270.         return $this;
  271.     }
  272.     public function getDescription(): ?string
  273.     {
  274.         return $this->description;
  275.     }
  276.     public function setDescription(?string $description): self
  277.     {
  278.         $this->description $description;
  279.         return $this;
  280.     }
  281.     public function getWebsite(): ?string
  282.     {
  283.         return $this->website;
  284.     }
  285.     public function setWebsite(?string $website): self
  286.     {
  287.         $this->website $website;
  288.         return $this;
  289.     }
  290.     public function getFacebook(): ?string
  291.     {
  292.         return $this->facebook;
  293.     }
  294.     public function setFacebook(?string $facebook): self
  295.     {
  296.         $this->facebook $facebook;
  297.         return $this;
  298.     }
  299.     public function getTwitter(): ?string
  300.     {
  301.         return $this->twitter;
  302.     }
  303.     public function setTwitter(?string $twitter): self
  304.     {
  305.         $this->twitter $twitter;
  306.         return $this;
  307.     }
  308.     public function getInstagram(): ?string
  309.     {
  310.         return $this->instagram;
  311.     }
  312.     public function setInstagram(?string $instagram): self
  313.     {
  314.         $this->instagram $instagram;
  315.         return $this;
  316.     }
  317.     public function getYoutube(): ?string
  318.     {
  319.         return $this->youtube;
  320.     }
  321.     public function setYoutube(?string $youtube): self
  322.     {
  323.         $this->youtube $youtube;
  324.         return $this;
  325.     }
  326.     public function getTiktok(): ?string
  327.     {
  328.         return $this->tiktok;
  329.     }
  330.     public function setTiktok(?string $tiktok): self
  331.     {
  332.         $this->tiktok $tiktok;
  333.         return $this;
  334.     }
  335.     public function getRc(): ?string
  336.     {
  337.         return $this->rc;
  338.     }
  339.     public function setRc(?string $rc): self
  340.     {
  341.         $this->rc $rc;
  342.         return $this;
  343.     }
  344.     public function getNif(): ?string
  345.     {
  346.         return $this->nif;
  347.     }
  348.     public function setNif(?string $nif): self
  349.     {
  350.         $this->nif $nif;
  351.         return $this;
  352.     }
  353.     public function getNis(): ?string
  354.     {
  355.         return $this->nis;
  356.     }
  357.     public function setNis(?string $nis): self
  358.     {
  359.         $this->nis $nis;
  360.         return $this;
  361.     }
  362.     public function getIsActive(): ?bool
  363.     {
  364.         return $this->is_active;
  365.     }
  366.     public function setIsActive(bool $is_active): self
  367.     {
  368.         $this->is_active $is_active;
  369.         return $this;
  370.     }
  371.     public function getType(): ?CompanyCategory
  372.     {
  373.         return $this->type;
  374.     }
  375.     public function setType(?CompanyCategory $type): self
  376.     {
  377.         $this->type $type;
  378.         return $this;
  379.     }
  380.     /**
  381.      * @return Collection<int, User>
  382.      */
  383.     public function getUsers(): Collection
  384.     {
  385.         return $this->users;
  386.     }
  387.     public function addUser(User $user): self
  388.     {
  389.         if (!$this->users->contains($user)) {
  390.             $this->users[] = $user;
  391.             $user->setCompany($this);
  392.         }
  393.         return $this;
  394.     }
  395.     public function removeUser(User $user): self
  396.     {
  397.         if ($this->users->removeElement($user)) {
  398.             // set the owning side to null (unless already changed)
  399.             if ($user->getCompany() === $this) {
  400.                 $user->setCompany(null);
  401.             }
  402.         }
  403.         return $this;
  404.     }
  405.     public function getSize(): ?string
  406.     {
  407.         return $this->size;
  408.     }
  409.     public function setSize(?string $size): self
  410.     {
  411.         $this->size $size;
  412.         return $this;
  413.     }
  414.     public function getAddress(): ?Location
  415.     {
  416.         return $this->address;
  417.     }
  418.     public function setAddress(?Location $address): self
  419.     {
  420.         $this->address $address;
  421.         return $this;
  422.     }
  423.     public function getDateFormat(): ?string
  424.     {
  425.         return $this->date_format;
  426.     }
  427.     public function setDateFormat(?string $date_format): self
  428.     {
  429.         $this->date_format $date_format;
  430.         return $this;
  431.     }
  432.     public function getLanguege(): ?string
  433.     {
  434.         return $this->languege;
  435.     }
  436.     public function setLanguege(?string $languege): self
  437.     {
  438.         $this->languege $languege;
  439.         return $this;
  440.     }
  441.     public function getCurrencie(): ?string
  442.     {
  443.         return $this->currencie;
  444.     }
  445.     public function setCurrencie(?string $currencie): self
  446.     {
  447.         $this->currencie $currencie;
  448.         return $this;
  449.     }
  450.     public function getTimeZone(): ?string
  451.     {
  452.         return $this->time_zone;
  453.     }
  454.     public function setTimeZone(?string $time_zone): self
  455.     {
  456.         $this->time_zone $time_zone;
  457.         return $this;
  458.     }
  459.     /**
  460.      * @return Collection<int, Expense>
  461.      */
  462.     public function getExpenses(): Collection
  463.     {
  464.         return $this->expenses;
  465.     }
  466.     public function addExpense(Expense $expense): self
  467.     {
  468.         if (!$this->expenses->contains($expense)) {
  469.             $this->expenses[] = $expense;
  470.             $expense->setOwner($this);
  471.         }
  472.         return $this;
  473.     }
  474.     public function removeExpense(Expense $expense): self
  475.     {
  476.         if ($this->expenses->removeElement($expense)) {
  477.             // set the owning side to null (unless already changed)
  478.             if ($expense->getOwner() === $this) {
  479.                 $expense->setOwner(null);
  480.             }
  481.         }
  482.         return $this;
  483.     }
  484.     /**
  485.      * @return Collection<int, ExpenseCategory>
  486.      */
  487.     public function getExpenseCategories(): Collection
  488.     {
  489.         return $this->expenseCategories;
  490.     }
  491.     public function addExpenseCategory(ExpenseCategory $expenseCategory): self
  492.     {
  493.         if (!$this->expenseCategories->contains($expenseCategory)) {
  494.             $this->expenseCategories[] = $expenseCategory;
  495.             $expenseCategory->setOwner($this);
  496.         }
  497.         return $this;
  498.     }
  499.     public function removeExpenseCategory(ExpenseCategory $expenseCategory): self
  500.     {
  501.         if ($this->expenseCategories->removeElement($expenseCategory)) {
  502.             // set the owning side to null (unless already changed)
  503.             if ($expenseCategory->getOwner() === $this) {
  504.                 $expenseCategory->setOwner(null);
  505.             }
  506.         }
  507.         return $this;
  508.     }
  509.     /**
  510.      * @return Collection<int, Season>
  511.      */
  512.     public function getSeasons(): Collection
  513.     {
  514.         return $this->seasons;
  515.     }
  516.     public function addSeason(Season $season): self
  517.     {
  518.         if (!$this->seasons->contains($season)) {
  519.             $this->seasons[] = $season;
  520.             $season->setOwner($this);
  521.         }
  522.         return $this;
  523.     }
  524.     public function getActiveSeason(): Season|null
  525.     {
  526.         $seasons $this->getSeasons();
  527.         foreach ($seasons as $season) {
  528.             if ($season->isIsActive()) {
  529.                 return $season;
  530.             }
  531.         }
  532.         return null;
  533.     }
  534.     public function removeSeason(Season $season): self
  535.     {
  536.         if ($this->seasons->removeElement($season)) {
  537.             // set the owning side to null (unless already changed)
  538.             if ($season->getOwner() === $this) {
  539.                 $season->setOwner(null);
  540.             }
  541.         }
  542.         return $this;
  543.     }
  544.     /**
  545.      * @return Collection<int, Service>
  546.      */
  547.     public function getServices(): Collection
  548.     {
  549.         return $this->services;
  550.     }
  551.     public function addService(Service $service): self
  552.     {
  553.         if (!$this->services->contains($service)) {
  554.             $this->services[] = $service;
  555.             $service->setOwner($this);
  556.         }
  557.         return $this;
  558.     }
  559.     public function removeService(Service $service): self
  560.     {
  561.         if ($this->services->removeElement($service)) {
  562.             // set the owning side to null (unless already changed)
  563.             if ($service->getOwner() === $this) {
  564.                 $service->setOwner(null);
  565.             }
  566.         }
  567.         return $this;
  568.     }
  569.     /**
  570.      * @return Collection<int, Section>
  571.      */
  572.     public function getSections(): Collection
  573.     {
  574.         return $this->sections;
  575.     }
  576.     public function addSection(Section $section): self
  577.     {
  578.         if (!$this->sections->contains($section)) {
  579.             $this->sections[] = $section;
  580.             $section->setOwner($this);
  581.         }
  582.         return $this;
  583.     }
  584.     public function removeSection(Section $section): self
  585.     {
  586.         if ($this->sections->removeElement($section)) {
  587.             // set the owning side to null (unless already changed)
  588.             if ($section->getOwner() === $this) {
  589.                 $section->setOwner(null);
  590.             }
  591.         }
  592.         return $this;
  593.     }
  594.     /**
  595.      * @return Collection<int, FamilyMember>
  596.      */
  597.     public function getFamilyMembers(): Collection
  598.     {
  599.         return $this->familyMembers;
  600.     }
  601.     public function addFamilyMember(FamilyMember $familyMember): self
  602.     {
  603.         if (!$this->familyMembers->contains($familyMember)) {
  604.             $this->familyMembers[] = $familyMember;
  605.             $familyMember->setOwner($this);
  606.         }
  607.         return $this;
  608.     }
  609.     public function removeFamilyMember(FamilyMember $familyMember): self
  610.     {
  611.         if ($this->familyMembers->removeElement($familyMember)) {
  612.             // set the owning side to null (unless already changed)
  613.             if ($familyMember->getOwner() === $this) {
  614.                 $familyMember->setOwner(null);
  615.             }
  616.         }
  617.         return $this;
  618.     }
  619.     /**
  620.      * @return Collection<int, Child>
  621.      */
  622.     public function getChildren(): Collection
  623.     {
  624.         return $this->children;
  625.     }
  626.     public function addChild(Child $child): self
  627.     {
  628.         if (!$this->children->contains($child)) {
  629.             $this->children[] = $child;
  630.             $child->setOwner($this);
  631.         }
  632.         return $this;
  633.     }
  634.     public function removeChild(Child $child): self
  635.     {
  636.         if ($this->children->removeElement($child)) {
  637.             // set the owning side to null (unless already changed)
  638.             if ($child->getOwner() === $this) {
  639.                 $child->setOwner(null);
  640.             }
  641.         }
  642.         return $this;
  643.     }
  644.     /**
  645.      * @return Collection<int, Employee>
  646.      */
  647.     public function getEmployees(): Collection
  648.     {
  649.         return $this->employees;
  650.     }
  651.     public function addEmployee(Employee $employee): self
  652.     {
  653.         if (!$this->employees->contains($employee)) {
  654.             $this->employees[] = $employee;
  655.             $employee->setOwner($this);
  656.         }
  657.         return $this;
  658.     }
  659.     public function removeEmployee(Employee $employee): self
  660.     {
  661.         if ($this->employees->removeElement($employee)) {
  662.             // set the owning side to null (unless already changed)
  663.             if ($employee->getOwner() === $this) {
  664.                 $employee->setOwner(null);
  665.             }
  666.         }
  667.         return $this;
  668.     }
  669.     /**
  670.      * @return Collection<int, Subscription>
  671.      */
  672.     public function getSubscriptions(): Collection
  673.     {
  674.         return $this->subscriptions;
  675.     }
  676.     public function addSubscription(Subscription $subscription): self
  677.     {
  678.         if (!$this->subscriptions->contains($subscription)) {
  679.             $this->subscriptions[] = $subscription;
  680.             $subscription->setOwner($this);
  681.         }
  682.         return $this;
  683.     }
  684.     public function removeSubscription(Subscription $subscription): self
  685.     {
  686.         if ($this->subscriptions->removeElement($subscription)) {
  687.             // set the owning side to null (unless already changed)
  688.             if ($subscription->getOwner() === $this) {
  689.                 $subscription->setOwner(null);
  690.             }
  691.         }
  692.         return $this;
  693.     }
  694.     /**
  695.      * @return Collection<int, Payment>
  696.      */
  697.     public function getPayments(): Collection
  698.     {
  699.         return $this->payments;
  700.     }
  701.     public function addPayment(Payment $payment): self
  702.     {
  703.         if (!$this->payments->contains($payment)) {
  704.             $this->payments[] = $payment;
  705.             $payment->setOwner($this);
  706.         }
  707.         return $this;
  708.     }
  709.     public function removePayment(Payment $payment): self
  710.     {
  711.         if ($this->payments->removeElement($payment)) {
  712.             // set the owning side to null (unless already changed)
  713.             if ($payment->getOwner() === $this) {
  714.                 $payment->setOwner(null);
  715.             }
  716.         }
  717.         return $this;
  718.     }
  719.     /**
  720.      * @return Collection<int, Classroom>
  721.      */
  722.     public function getClassrooms(): Collection
  723.     {
  724.         return $this->classrooms;
  725.     }
  726.     public function addClassroom(Classroom $classroom): self
  727.     {
  728.         if (!$this->classrooms->contains($classroom)) {
  729.             $this->classrooms[] = $classroom;
  730.             $classroom->setOwner($this);
  731.         }
  732.         return $this;
  733.     }
  734.     public function removeClassroom(Classroom $classroom): self
  735.     {
  736.         if ($this->classrooms->removeElement($classroom)) {
  737.             // set the owning side to null (unless already changed)
  738.             if ($classroom->getOwner() === $this) {
  739.                 $classroom->setOwner(null);
  740.             }
  741.         }
  742.         return $this;
  743.     }
  744.     /**
  745.      * @return Collection<int, Evenement>
  746.      */
  747.     public function getEvenements(): Collection
  748.     {
  749.         return $this->evenements;
  750.     }
  751.     public function addEvenement(Evenement $evenement): self
  752.     {
  753.         if (!$this->evenements->contains($evenement)) {
  754.             $this->evenements[] = $evenement;
  755.             $evenement->setOwner($this);
  756.         }
  757.         return $this;
  758.     }
  759.     public function removeEvenement(Evenement $evenement): self
  760.     {
  761.         if ($this->evenements->removeElement($evenement)) {
  762.             // set the owning side to null (unless already changed)
  763.             if ($evenement->getOwner() === $this) {
  764.                 $evenement->setOwner(null);
  765.             }
  766.         }
  767.         return $this;
  768.     }
  769.     /**
  770.      * @return Collection<int, Task>
  771.      */
  772.     public function getTasks(): Collection
  773.     {
  774.         return $this->tasks;
  775.     }
  776.     public function addTask(Task $task): self
  777.     {
  778.         if (!$this->tasks->contains($task)) {
  779.             $this->tasks[] = $task;
  780.             $task->setOwner($this);
  781.         }
  782.         return $this;
  783.     }
  784.     public function removeTask(Task $task): self
  785.     {
  786.         if ($this->tasks->removeElement($task)) {
  787.             // set the owning side to null (unless already changed)
  788.             if ($task->getOwner() === $this) {
  789.                 $task->setOwner(null);
  790.             }
  791.         }
  792.         return $this;
  793.     }
  794.     /**
  795.      * @return Collection<int, AbsenceEmployee>
  796.      */
  797.     public function getAbsenceEmployees(): Collection
  798.     {
  799.         return $this->absenceEmployees;
  800.     }
  801.     public function addAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
  802.     {
  803.         if (!$this->absenceEmployees->contains($absenceEmployee)) {
  804.             $this->absenceEmployees[] = $absenceEmployee;
  805.             $absenceEmployee->setOwner($this);
  806.         }
  807.         return $this;
  808.     }
  809.     public function removeAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
  810.     {
  811.         if ($this->absenceEmployees->removeElement($absenceEmployee)) {
  812.             // set the owning side to null (unless already changed)
  813.             if ($absenceEmployee->getOwner() === $this) {
  814.                 $absenceEmployee->setOwner(null);
  815.             }
  816.         }
  817.         return $this;
  818.     }
  819.     /**
  820.      * @return Collection<int, Post>
  821.      */
  822.     public function getPosts(): Collection
  823.     {
  824.         return $this->posts;
  825.     }
  826.     public function addPost(Post $post): self
  827.     {
  828.         if (!$this->posts->contains($post)) {
  829.             $this->posts[] = $post;
  830.             $post->setOwner($this);
  831.         }
  832.         return $this;
  833.     }
  834.     public function removePost(Post $post): self
  835.     {
  836.         if ($this->posts->removeElement($post)) {
  837.             // set the owning side to null (unless already changed)
  838.             if ($post->getOwner() === $this) {
  839.                 $post->setOwner(null);
  840.             }
  841.         }
  842.         return $this;
  843.     }
  844.     /**
  845.      * @return Collection<int, Colleague>
  846.      */
  847.     public function getColleagues(): Collection
  848.     {
  849.         return $this->colleagues;
  850.     }
  851.     public function addColleague(Colleague $colleague): self
  852.     {
  853.         if (!$this->colleagues->contains($colleague)) {
  854.             $this->colleagues[] = $colleague;
  855.             $colleague->setOwner($this);
  856.         }
  857.         return $this;
  858.     }
  859.     public function removeColleague(Colleague $colleague): self
  860.     {
  861.         if ($this->colleagues->removeElement($colleague)) {
  862.             // set the owning side to null (unless already changed)
  863.             if ($colleague->getOwner() === $this) {
  864.                 $colleague->setOwner(null);
  865.             }
  866.         }
  867.         return $this;
  868.     }
  869.     /**
  870.      * @return Collection<int, Abonnement>
  871.      */
  872.     public function getAbonnements(): Collection
  873.     {
  874.         foreach ($this->abonnements as $key => $value) {
  875.             if ($value->getExpireDate() < new DateTime()) {
  876.                 $this->abonnements->remove($key);
  877.             }
  878.         }
  879.         return $this->abonnements;
  880.     }
  881.     public function addAbonnement(Abonnement $abonnement): self
  882.     {
  883.         if (!$this->abonnements->contains($abonnement)) {
  884.             $this->abonnements[] = $abonnement;
  885.             $abonnement->setOwner($this);
  886.         }
  887.         return $this;
  888.     }
  889.     public function removeAbonnement(Abonnement $abonnement): self
  890.     {
  891.         if ($this->abonnements->removeElement($abonnement)) {
  892.             // set the owning side to null (unless already changed)
  893.             if ($abonnement->getOwner() === $this) {
  894.                 $abonnement->setOwner(null);
  895.             }
  896.         }
  897.         return $this;
  898.     }
  899.     /**
  900.      * @return Collection<int, Order>
  901.      */
  902.     public function getOrders(): Collection
  903.     {
  904.         return $this->orders;
  905.     }
  906.     public function addOrder(Order $order): self
  907.     {
  908.         if (!$this->orders->contains($order)) {
  909.             $this->orders[] = $order;
  910.             $order->setOwner($this);
  911.         }
  912.         return $this;
  913.     }
  914.     public function removeOrder(Order $order): self
  915.     {
  916.         if ($this->orders->removeElement($order)) {
  917.             // set the owning side to null (unless already changed)
  918.             if ($order->getOwner() === $this) {
  919.                 $order->setOwner(null);
  920.             }
  921.         }
  922.         return $this;
  923.     }
  924.     /**
  925.      * @return Collection<int, Prechild>
  926.      */
  927.     public function getPrechildren(): Collection
  928.     {
  929.         return $this->prechildren;
  930.     }
  931.     public function addPrechild(Prechild $prechild): self
  932.     {
  933.         if (!$this->prechildren->contains($prechild)) {
  934.             $this->prechildren[] = $prechild;
  935.             $prechild->setOwner($this);
  936.         }
  937.         return $this;
  938.     }
  939.     public function removePrechild(Prechild $prechild): self
  940.     {
  941.         if ($this->prechildren->removeElement($prechild)) {
  942.             // set the owning side to null (unless already changed)
  943.             if ($prechild->getOwner() === $this) {
  944.                 $prechild->setOwner(null);
  945.             }
  946.         }
  947.         return $this;
  948.     }
  949.     /**
  950.      * @return Collection<int, Pointing>
  951.      */
  952.     public function getPointings(): Collection
  953.     {
  954.         return $this->pointings;
  955.     }
  956.     public function addPointing(Pointing $pointing): self
  957.     {
  958.         if (!$this->pointings->contains($pointing)) {
  959.             $this->pointings[] = $pointing;
  960.             $pointing->setOwner($this);
  961.         }
  962.         return $this;
  963.     }
  964.     public function removePointing(Pointing $pointing): self
  965.     {
  966.         if ($this->pointings->removeElement($pointing)) {
  967.             // set the owning side to null (unless already changed)
  968.             if ($pointing->getOwner() === $this) {
  969.                 $pointing->setOwner(null);
  970.             }
  971.         }
  972.         return $this;
  973.     }
  974.     public function isIsActive(): ?bool
  975.     {
  976.         return $this->is_active;
  977.     }
  978.     /**
  979.      * @return Collection<int, Activity>
  980.      */
  981.     public function getActivities(): Collection
  982.     {
  983.         return $this->activities;
  984.     }
  985.     public function addActivity(Activity $activity): static
  986.     {
  987.         if (!$this->activities->contains($activity)) {
  988.             $this->activities->add($activity);
  989.             $activity->setOwner($this);
  990.         }
  991.         return $this;
  992.     }
  993.     public function removeActivity(Activity $activity): static
  994.     {
  995.         if ($this->activities->removeElement($activity)) {
  996.             // set the owning side to null (unless already changed)
  997.             if ($activity->getOwner() === $this) {
  998.                 $activity->setOwner(null);
  999.             }
  1000.         }
  1001.         return $this;
  1002.     }
  1003.     public function getOwner(): User|null
  1004.     {
  1005.         foreach ($this->users as $user) {
  1006.             if (in_array('ROLE_OWNER'$user->getRoles())) {
  1007.                 return $user;
  1008.             }
  1009.         }
  1010.         return null;
  1011.     }
  1012. }