src/Entity/Tutoring/Meeting.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Tutoring;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Tutoring\MeetingRepository;
  5. use App\Traits\Actions;
  6. use App\Entity\Tutoring\Month;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * Meeting
  11.  */
  12. #[ORM\Entity(repositoryClassMeetingRepository::class)]
  13. #[ORM\Table(name'hs_tc_tutoring_meeting')]
  14. #[ApiResource]
  15. class Meeting
  16. {
  17.     use Actions;
  18.     #[ORM\ManyToOne(targetEntityMonth::class, cascade: ['persist'], inversedBy'meetings')]
  19.     private ?Month $month null;
  20.     #[ORM\OneToMany(mappedBy'meeting'targetEntityPresence::class, cascade: ['persist'], orphanRemovaltrue)]
  21.     private ?Collection $presences null;
  22.     public function __construct()
  23.     {
  24.         
  25.         $this->createAt=new \DateTime('now');
  26.         $this->published=true;
  27.     }
  28.     /**
  29.      * Set month
  30.      *
  31.      *
  32.      * @return Meeting
  33.      */
  34.     public function setMonth(Month $month null)
  35.     {
  36.         $this->month $month;
  37.         return $this;
  38.     }
  39.     /**
  40.      * Get month
  41.      *
  42.      * @return \App\Entity\Tutoring\Month
  43.      */
  44.     public function getMonth()
  45.     {
  46.         return $this->month;
  47.     }
  48.     public function getNameDay($format){
  49.         switch ($format){
  50.             case 'short':
  51.                 $days=['','Lun''Mar''Mer''Jeu''Ven''Sam','Di'];
  52.                 return $days[$this->createAt->format('N')].' '.$this->createAt->format("d");
  53.             case 'long':
  54.                 $days=['','Lundi''Mardi''Mercredi''Jeudi''Vendredi''Samedi','Dimanche'];
  55.                 return $days[$this->createAt->format('N')].' '.$this->createAt->format("d/m");
  56.         }
  57.     }
  58.     /**
  59.      * Add presence
  60.      *
  61.      *
  62.      * @return Meeting
  63.      */
  64.     public function addPresence(Presence $presence)
  65.     {
  66.         $presence->setMeeting($this);
  67.         $this->presences[] = $presence;
  68.         return $this;
  69.     }
  70.     /**
  71.      * Remove presence
  72.      */
  73.     public function removePresence(Presence $presence)
  74.     {
  75.         $this->presences->removeElement($presence);
  76.     }
  77.     /**
  78.      * Get presences
  79.      *
  80.      * @return \Doctrine\Common\Collections\Collection
  81.      */
  82.     public function getPresences()
  83.     {
  84.         return $this->presences;
  85.     }
  86.     public function setCreateAt(\DateTime $createAt): void
  87.     {
  88.         $this->createAt $createAt;
  89.     }
  90.     public function isPassed(): bool
  91.     {
  92.         $today=new \DateTime('now');
  93.         return $this->createAt$today;
  94.     }
  95. }