src/Entity/Main/Formule.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Main;
  3. use App\Repository\FormuleRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Vich\UploaderBundle\Entity\File as EmbeddedFile;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\HttpFoundation\File\UploadedFile;
  11. /**
  12.  * @ORM\Entity(repositoryClass=FormuleRepository::class)
  13.  * @Vich\Uploadable
  14.  */
  15. class Formule
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=60, nullable=true)
  25.      */
  26.     private $designation;
  27.     /**
  28.      * @ORM\Column(type="string", length=60, nullable=true)
  29.      */
  30.     private $code;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $url_formule;
  35.     /**
  36.      * @ORM\Column(type="integer", nullable=true)
  37.      */
  38.     private $temps_limite_resa;
  39.     /**
  40.      * @ORM\Column(type="integer", nullable=true)
  41.      */
  42.     private $nbre_mini;
  43.     /**
  44.      * @ORM\Column(type="integer", nullable=true)
  45.      */
  46.     private $nbre_maxi;
  47.     /**
  48.      * @ORM\Column(type="integer", nullable=true)
  49.      */
  50.     private $presence_avant;
  51.     /**
  52.      * @ORM\Column(type="boolean", nullable=true)
  53.      */
  54.     private $is_creneau_activity;
  55.     /**
  56.      * @ORM\Column(type="time", nullable=true)
  57.      */
  58.     private $heure_ouverture_creneau;
  59.     /**
  60.      * @ORM\Column(type="time", nullable=true)
  61.      */
  62.     private $heure_fermeture_creneau;
  63.     /**
  64.      * @ORM\Column(type="integer", nullable=true)
  65.      */
  66.     private $temps_creneau;
  67.     /**
  68.      * @ORM\Column(type="integer", nullable=true)
  69.      */
  70.     private $priority;
  71.     /**
  72.      * @ORM\Column(type="boolean")
  73.      */
  74.     private $actif false;
  75.     /**
  76.      * @ORM\Column(type="text", nullable=true)
  77.      */
  78.     private $description;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      */
  82.     private $image;
  83.     /**
  84.      * @Vich\UploadableField(mapping="product_images", fileNameProperty="image")
  85.      * @var File
  86.      */
  87.     private $imageFile;
  88.     /**
  89.      * @ORM\Column(type="datetime")
  90.      */
  91.     private $updated_at;
  92.     /**
  93.      * @ORM\OneToMany(targetEntity="App\Entity\Main\Forfait", mappedBy="formule")
  94.      */
  95.     private $forfaits;
  96.     public function __construct()
  97.     {
  98.         $this->forfaits = new ArrayCollection();
  99.         $this->updated_at = new \DateTime('now');
  100.     }
  101.     
  102.     public function __toString()
  103.     {
  104.         return (string) $this->designation;
  105.     }
  106.     public function getId(): ?int
  107.     {
  108.         return $this->id;
  109.     }
  110.     public function getDesignation(): ?string
  111.     {
  112.         return $this->designation;
  113.     }
  114.     public function setDesignation(?string $designation): self
  115.     {
  116.         $this->designation $designation;
  117.         return $this;
  118.     }
  119.     public function getCode(): ?string
  120.     {
  121.         return $this->code;
  122.     }
  123.     public function setCode(?string $code): self
  124.     {
  125.         $this->code $code;
  126.         return $this;
  127.     }
  128.     public function getUrlFormule(): ?string
  129.     {
  130.         return $this->url_formule;
  131.     }
  132.     public function setUrlFormule(?string $url_formule): self
  133.     {
  134.         $this->url_formule $url_formule;
  135.         return $this;
  136.     }
  137.     public function getTempsLimiteResa(): ?int
  138.     {
  139.         return $this->temps_limite_resa;
  140.     }
  141.     public function setTempsLimiteResa(?int $temps_limite_resa): self
  142.     {
  143.         $this->temps_limite_resa $temps_limite_resa;
  144.         return $this;
  145.     }
  146.     public function getNbreMini(): ?int
  147.     {
  148.         return $this->nbre_mini;
  149.     }
  150.     public function setNbreMini(?int $nbre_mini): self
  151.     {
  152.         $this->nbre_mini $nbre_mini;
  153.         return $this;
  154.     }
  155.     public function getNbreMaxi(): ?int
  156.     {
  157.         return $this->nbre_maxi;
  158.     }
  159.     public function setNbreMaxi(?int $nbre_maxi): self
  160.     {
  161.         $this->nbre_maxi $nbre_maxi;
  162.         return $this;
  163.     }
  164.     public function getPresenceAvant(): ?int
  165.     {
  166.         return $this->presence_avant;
  167.     }
  168.     public function setPresenceAvant(?int $presence_avant): self
  169.     {
  170.         $this->presence_avant $presence_avant;
  171.         return $this;
  172.     }
  173.     public function getIsCreneauActivity(): ?bool
  174.     {
  175.         return $this->is_creneau_activity;
  176.     }
  177.     public function setIsCreneauActivity(?bool $is_creneau_activity): self
  178.     {
  179.         $this->is_creneau_activity $is_creneau_activity;
  180.         return $this;
  181.     }
  182.     public function getHeureOuvertureCreneau(): ?\DateTimeInterface
  183.     {
  184.         return $this->heure_ouverture_creneau;
  185.     }
  186.     public function setHeureOuvertureCreneau(?\DateTimeInterface $heure_ouverture_creneau): self
  187.     {
  188.         $this->heure_ouverture_creneau $heure_ouverture_creneau;
  189.         return $this;
  190.     }
  191.     public function getHeureFermetureCreneau(): ?\DateTimeInterface
  192.     {
  193.         return $this->heure_fermeture_creneau;
  194.     }
  195.     public function setHeureFermetureCreneau(?\DateTimeInterface $heure_fermeture_creneau): self
  196.     {
  197.         $this->heure_fermeture_creneau $heure_fermeture_creneau;
  198.         return $this;
  199.     }
  200.     public function getTempsCreneau(): ?int
  201.     {
  202.         return $this->temps_creneau;
  203.     }
  204.     public function setTempsCreneau(?int $temps_creneau): self
  205.     {
  206.         $this->temps_creneau $temps_creneau;
  207.         return $this;
  208.     }
  209.     public function getPriority(): ?int
  210.     {
  211.         return $this->priority;
  212.     }
  213.     public function setPriority(?int $priority): self
  214.     {
  215.         $this->priority $priority;
  216.         return $this;
  217.     }
  218.     public function getActif(): ?bool
  219.     {
  220.         return $this->actif;
  221.     }
  222.     public function setActif(bool $actif): self
  223.     {
  224.         $this->actif $actif;
  225.         return $this;
  226.     }
  227.     public function getDescription(): ?string
  228.     {
  229.         return $this->description;
  230.     }
  231.     public function setDescription(?string $description): self
  232.     {
  233.         $this->description $description;
  234.         return $this;
  235.     }
  236.     public function getImage(): ?string
  237.     {
  238.         return $this->image;
  239.     }
  240.     public function setImage(?string $image): self
  241.     {
  242.         $this->image $image;
  243.         return $this;
  244.     }
  245.     public function setImageFile(File $image null)
  246.     {
  247.         $this->imageFile $image;
  248.         if ($image) {
  249.             $this->updatedAt = new \DateTime('now');
  250.         }
  251.     }
  252.     public function getImageFile()
  253.     {
  254.         return $this->imageFile;
  255.     }
  256.     public function getUpdatedAt(): ?\DateTimeInterface
  257.     {
  258.         return $this->updated_at;
  259.     }
  260.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  261.     {
  262.         $this->updated_at $updated_at;
  263.         return $this;
  264.     }
  265.     /**
  266.      * @return Collection|Forfait[]
  267.      */
  268.     public function getForfaits(): Collection
  269.     {
  270.         // Collect an array iterator.
  271.         $iterator $this->forfaits->getIterator();
  272.         // Do sort the new iterator.
  273.         $iterator->uasort(function ($a$b) {
  274.             return ($a->getPriority() < $b->getPriority()) ? -1;
  275.         });
  276.         // pass sorted array to a new ArrayCollection.
  277.         $this->forfaits = new \Doctrine\Common\Collections\ArrayCollection(iterator_to_array($iterator));
  278.         return $this->forfaits;
  279.     }
  280.     public function addForfait(Forfait $forfait): self
  281.     {
  282.         if (!$this->forfaits->contains($forfait)) {
  283.             $this->forfaits[] = $forfait;
  284.             $forfait->setFormules($this);
  285.         }
  286.         return $this;
  287.     }
  288.     public function removeForfait(Forfait $forfait): self
  289.     {
  290.         if ($this->forfaits->contains($forfait)) {
  291.             $this->forfaits->removeElement($forfait);
  292.             // set the owning side to null (unless already changed)
  293.             if ($forfait->getFormules() === $this) {
  294.                 $forfait->setFormules(null);
  295.             }
  296.         }
  297.         return $this;
  298.     }
  299. }