src/Entity/ActiviteDisponibilite.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ActiviteDisponibiliteRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity(repositoryClass=ActiviteDisponibiliteRepository::class)
  10.  */
  11. class ActiviteDisponibilite
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="activiteDisponibilites")
  21.      * @ORM\JoinColumn(nullable=false)
  22.      */
  23.     private $user;
  24.     /**
  25.      * @ORM\Column(type="datetime")
  26.      */
  27.     private $debut;
  28.     /**
  29.      * @ORM\Column(type="datetime")
  30.      */
  31.     private $fin;
  32.     /**
  33.     * @ORM\Column(type="datetime")
  34.     * @Gedmo\Timestampable(on="create")
  35.     */
  36.     private $createdAt;
  37.     /**
  38.      * @ORM\Column(type="string", length=50)
  39.      */
  40.     private $type;
  41.     /**
  42.      * @ORM\Column(type="string", length=255)
  43.      */
  44.     private $ts;
  45.     /**
  46.      * @ORM\OneToMany(targetEntity=ActiviteDisponibiliteInscription::class, mappedBy="dispo")
  47.      */
  48.     private $activiteDisponibiliteInscriptions;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity=UserEnseignantLieu::class, inversedBy="activiteDisponibilites")
  51.      */
  52.     private $lieu;
  53.     /**
  54.      * @ORM\ManyToOne(targetEntity=ShopCategorie::class)
  55.      * @ORM\JoinColumn(nullable=false)
  56.      */
  57.     private $categorie;
  58.     /**
  59.      * @ORM\Column(type="text", nullable=true)
  60.      */
  61.     private $typeVehicule;
  62.     public static $typesVehicules = ['MANUEL''AUTOMATIQUE'];
  63.     /**
  64.      * @ORM\Column(type="text", nullable=true)
  65.      */
  66.     private $typeTerrain;
  67.     public static $typesTerrains = ['ROUTE''SIMULATEUR''PLATEAU''CIRCULATION'];
  68.     /**
  69.      * @ORM\Column(type="boolean")
  70.      */
  71.     private $passerelle false;
  72.     public function __construct()
  73.     {
  74.         $this->activiteDisponibiliteInscriptions = new ArrayCollection();
  75.     }
  76.     public function getId(): ?int
  77.     {
  78.         return $this->id;
  79.     }
  80.     public function getUser(): ?User
  81.     {
  82.         return $this->user;
  83.     }
  84.     public function setUser(?User $user): self
  85.     {
  86.         $this->user $user;
  87.         return $this;
  88.     }
  89.     public function getDebut(): ?\DateTimeInterface
  90.     {
  91.         return $this->debut;
  92.     }
  93.     public function setDebut(\DateTimeInterface $debut): self
  94.     {
  95.         $this->debut $debut;
  96.         return $this;
  97.     }
  98.     public function getFin(): ?\DateTimeInterface
  99.     {
  100.         return $this->fin;
  101.     }
  102.     public function setFin(\DateTimeInterface $fin): self
  103.     {
  104.         $this->fin $fin;
  105.         return $this;
  106.     }
  107.     public function getCreatedAt(): ?\DateTimeInterface {
  108.         return $this->createdAt;
  109.     }
  110.     public function setCreatedAt(?\DateTimeInterface $createdAt): self {
  111.         $this->createdAt $createdAt;
  112.                                                                         
  113.         return $this;
  114.     }
  115.     public function getType(): ?string
  116.     {
  117.         return $this->type;
  118.     }
  119.     public function setType(string $type): self
  120.     {
  121.         $this->type $type;
  122.         return $this;
  123.     }
  124.     public function getTs(): ?string
  125.     {
  126.         return $this->ts;
  127.     }
  128.     public function setTs(string $ts): self
  129.     {
  130.         $this->ts $ts;
  131.         return $this;
  132.     }
  133.     /**
  134.      * @return Collection|ActiviteDisponibiliteInscription[]
  135.      */
  136.     public function getActiviteDisponibiliteInscriptions(): Collection
  137.     {
  138.         return $this->activiteDisponibiliteInscriptions;
  139.     }
  140.     public function addActiviteDisponibiliteInscription(ActiviteDisponibiliteInscription $activiteDisponibiliteInscription): self
  141.     {
  142.         if (!$this->activiteDisponibiliteInscriptions->contains($activiteDisponibiliteInscription)) {
  143.             $this->activiteDisponibiliteInscriptions[] = $activiteDisponibiliteInscription;
  144.             $activiteDisponibiliteInscription->setDispo($this);
  145.         }
  146.         return $this;
  147.     }
  148.     public function removeActiviteDisponibiliteInscription(ActiviteDisponibiliteInscription $activiteDisponibiliteInscription): self
  149.     {
  150.         if ($this->activiteDisponibiliteInscriptions->removeElement($activiteDisponibiliteInscription)) {
  151.             // set the owning side to null (unless already changed)
  152.             if ($activiteDisponibiliteInscription->getDispo() === $this) {
  153.                 $activiteDisponibiliteInscription->setDispo(null);
  154.             }
  155.         }
  156.         return $this;
  157.     }
  158.     public function getLieu(): ?UserEnseignantLieu
  159.     {
  160.         return $this->lieu;
  161.     }
  162.     public function setLieu(?UserEnseignantLieu $lieu): self
  163.     {
  164.         $this->lieu $lieu;
  165.         return $this;
  166.     }
  167.     public function setCategorie(?ShopCategorie $categorie): self
  168.     {
  169.         $this->categorie $categorie;
  170.         return $this;
  171.     }
  172.     public function getCategorie(): ?ShopCategorie
  173.     {
  174.         return $this->categorie;
  175.     }
  176.     public function getTypeVehicule(): ?string
  177.     {
  178.         return $this->typeVehicule;
  179.     }
  180.     public function setTypeVehicule(?string $typeVehicule): self
  181.     {
  182.         $this->typeVehicule $typeVehicule;
  183.         return $this;
  184.     }
  185.     /**
  186.      * @ORM\PrePersist
  187.      * @ORM\PreUpdate
  188.      */
  189.     public function testTypeVehicule()
  190.     {
  191.         if(empty($this->typeVehicule)) return;
  192.         if (!in_array($this->typeVehiculeself::$typesVehicules)) {
  193.             throw new \UnexpectedValueException('typeVehicule ('.$this->typeVehicule.') expects one of: ' implode(', 'self::$typesVehicules));
  194.         }
  195.     }
  196.     public function getTypeTerrain(): ?string
  197.     {
  198.         return $this->typeTerrain;
  199.     }
  200.     public function setTypeTerrain(?string $typeTerrain): self
  201.     {
  202.         $this->typeTerrain $typeTerrain;
  203.         return $this;
  204.     }
  205.     /**
  206.      * @ORM\PrePersist
  207.      * @ORM\PreUpdate
  208.      */
  209.     public function testTypeTerrain()
  210.     {
  211.         if(empty($this->typeTerrain)) return;
  212.         if (!in_array($this->typeTerrainself::$typesTerrains)) {
  213.             throw new \UnexpectedValueException('typeTerrain ('.$this->typeTerrain.') expects one of: ' implode(', 'self::$typesTerrains));
  214.         }
  215.     }
  216.     public function getPasserelle(): ?bool
  217.     {
  218.         return $this->passerelle;
  219.     }
  220.     public function setPasserelle(bool $passerelle): self
  221.     {
  222.         $this->passerelle $passerelle;
  223.         return $this;
  224.     }
  225.     public function getHours(): int
  226.     {
  227.         $start $this->getDebut()->getTimestamp();
  228.         $end $this->getFin()->getTimestamp();
  229.         $interval $end $start;
  230.         $seconds $interval;
  231.         $hours $seconds/(60*60);
  232.         return $hours;
  233.     }
  234.     public function getCredits(): int
  235.     {
  236.         return $this->getHours();
  237.     }
  238. }