src/Entity/Tutoring/Presence.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Tutoring;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Tutoring\PresenceRepository;
  5. use App\Traits\Actions;
  6. use App\Entity\Tutoring\Month;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Presence
  10.  */
  11. #[ORM\Entity(repositoryClassPresenceRepository::class)]
  12. #[ORM\Table(name'hs_tc_tutoring_presence')]
  13. #[ApiResource]
  14. class Presence
  15. {
  16.     use Actions;
  17.     #[ORM\ManyToOne(targetEntityRowscourse::class, inversedBy'presences')]
  18.     #[ORM\JoinColumn(nullablefalse)]
  19.     private ?Rowscourse $rowscourse null;
  20.     
  21.     #[ORM\ManyToOne(targetEntityMeeting::class, inversedBy'presences')]
  22.     #[ORM\JoinColumn(nullablefalse)]
  23.     private ?Meeting $meeting null;
  24.     
  25.     public function __construct()
  26.     {
  27.         
  28.         $this->createAt=new \DateTime('now');
  29.         $this->published=true;
  30.     }
  31.     /**
  32.      * @return Meeting
  33.      */
  34.     public function getMeeting(): ?Meeting
  35.     {
  36.         return $this->meeting;
  37.     }
  38.     /**
  39.      * @param Meeting $meeting
  40.      */
  41.     public function setMeeting(?Meeting $meeting): Presence
  42.     {
  43.         $this->meeting $meeting;
  44.         return $this;
  45.     }
  46.     /**
  47.      * @return Rowscourse
  48.      */
  49.     public function getRowscourse(): ?Rowscourse
  50.     {
  51.         return $this->rowscourse;
  52.     }
  53.     /**
  54.      * @param Rowscourse $rowscourse
  55.      */
  56.     public function setRowscourse(?Rowscourse $rowscourse): Presence
  57.     {
  58.         $this->rowscourse $rowscourse;
  59.         return $this;
  60.     }
  61.     public function isAbondand(){
  62.         if($this->meeting->getMonth()->getStartAt()>=$this->rowscourse->getEndAt()) return true;
  63.         if($this->meeting->getMonth()->getEndAt()<=$this->rowscourse->getStartAt()) return true;
  64.         return false;
  65.     }
  66.     public function isPublished()
  67.     {
  68.         if(!$this->isAbondand()) return $this->published;
  69.         else return false;
  70.     }
  71.     public function getNameDay(){
  72.         $days=['Lundi','Mardi''Mardi''Mercredi''Jeudi''Vendredi''Samedi','Dimanche'];
  73.         return $days[$this->createAt->format('N')].' '.$this->createAt->format("d/m");
  74.     }
  75. }