src/Entity/Posts/Posts.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Posts;
  3. use App\Entity\Common\DatesTrait;
  4. use App\Entity\Common\IdTrait;
  5. use App\Entity\Common\OrdreTrait;
  6. use App\Entity\Common\SlugTrait;
  7. use App\Entity\User;
  8. use DateTimeImmutable;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Exception;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. use Symfony\Component\HttpFoundation\File\File;
  16. use Symfony\Component\HttpFoundation\File\UploadedFile;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  19. /**
  20.  * @ORM\Entity(repositoryClass="App\Repository\Posts\PostsRepository")
  21.  * @UniqueEntity("name")
  22.  * @Vich\Uploadable
  23.  */
  24. class Posts
  25. {
  26.     use IdTrait;
  27.     use OrdreTrait;
  28.     use DatesTrait;
  29.     use SlugTrait;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      * @Assert\NotBlank(message="Veuillez saisir le nom du post")
  33.      */
  34.     private $name;
  35.     /**
  36.      * @ORM\Column(type="string", length=500, nullable=true)
  37.      */
  38.     private $extrait;
  39.     /**
  40.      * @ORM\Column(type="text", nullable=true)
  41.      */
  42.     private $content;
  43.     /**
  44.      * @ORM\Column(type="boolean")
  45.      */
  46.     private $online;
  47.     /**
  48.      * @ORM\Column(type="integer", nullable=true, options={"default": 0})
  49.      */
  50.     private $views;
  51.     /**
  52.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  53.      *
  54.      * @Vich\UploadableField(mapping="posts_image", fileNameProperty="filename")
  55.      * @var File|null
  56.      * @Assert\Image(
  57.      *     mimeTypes={"image/jpeg", "image/png"},
  58.      *
  59.      *     maxHeight=1280,
  60.      *     maxWidth=1920,
  61.      *     maxHeightMessage="Votre image doit faire 1280 d'hauteur",
  62.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  63.      * )
  64.      */
  65.     private $imageFile;
  66.     /**
  67.      * @ORM\Column(type="string", length=255, nullable=true)
  68.      */
  69.     private $filename;
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="posts")
  72.      */
  73.     private $user;
  74.     /**
  75.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  76.      */
  77.     private $updatedBy;
  78.     /**
  79.      * @ORM\ManyToOne(targetEntity="App\Entity\Posts\Categorieposts", inversedBy="posts")
  80.      */
  81.     private $categories;
  82.     /**
  83.      * @ORM\OneToMany(targetEntity="App\Entity\Posts\Mediaposts", mappedBy="posts")
  84.      */
  85.     private $mediaposts;
  86.     /**
  87.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  88.      *
  89.      * @Vich\UploadableField(mapping="bandeau_posts", fileNameProperty="bandeaufile")
  90.      * @var File|null
  91.      * @Assert\Image(
  92.      *     mimeTypes={"image/jpeg", "image/png"},
  93.      *
  94.      *     maxHeight=230,
  95.      *     maxWidth=1920,
  96.      *     maxHeightMessage="Votre image doit faire 230 d'hauteur",
  97.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  98.      * )
  99.      */
  100.     private $imageBandeauFile;
  101.     /**
  102.      * @ORM\Column(type="string", length=255, nullable=true)
  103.      */
  104.     private $bandeaufile;
  105.     /**
  106.      * @ORM\Column(type="string", length=255, nullable=true)
  107.      */
  108.     private $email;
  109.     /**
  110.      * @ORM\Column(type="string", length=255, nullable=true)
  111.      */
  112.     private $telephone;
  113.     /**
  114.      * @ORM\Column(type="string", length=500, nullable=true)
  115.      */
  116.     private $lieu;
  117.     /**
  118.      * @ORM\Column(type="string", length=255, nullable=true)
  119.      */
  120.     private $heuredetravail;
  121.     /**
  122.      * @ORM\Column(type="string", length=255, nullable=true)
  123.      */
  124.     private $siteweb;
  125.     /**
  126.      * @ORM\Column(type="string", length=255, nullable=true)
  127.      */
  128.     private $facebook;
  129.     /**
  130.      * @ORM\Column(type="string", length=255, nullable=true)
  131.      */
  132.     private $twitter;
  133.     /**
  134.      * @ORM\Column(type="string", length=255, nullable=true)
  135.      */
  136.     private $instagram;
  137.     /**
  138.      * @ORM\Column(type="boolean")
  139.      */
  140.     private $reserved;
  141.     /**
  142.      * @ORM\Column(type="string", length=100, nullable=true)
  143.      */
  144.     private $longitude;
  145.     /**
  146.      * @ORM\Column(type="string", length=100, nullable=true)
  147.      */
  148.     private $latitude;
  149.     /**
  150.      * @ORM\Column(type="boolean")
  151.      */
  152.     private $featured;
  153.     public function getName(): ?string
  154.     {
  155.         return $this->name;
  156.     }
  157.     public function setName(string $name): self
  158.     {
  159.         $this->name $name;
  160.         return $this;
  161.     }
  162.     public function getExtrait(): ?string
  163.     {
  164.         return $this->extrait;
  165.     }
  166.     public function setExtrait(?string $extrait): self
  167.     {
  168.         $this->extrait $extrait;
  169.         return $this;
  170.     }
  171.     public function getContent(): ?string
  172.     {
  173.         return $this->content;
  174.     }
  175.     public function setContent(?string $content): self
  176.     {
  177.         $this->content $content;
  178.         return $this;
  179.     }
  180.     public function getOnline(): ?bool
  181.     {
  182.         return $this->online;
  183.     }
  184.     public function setOnline(bool $online): self
  185.     {
  186.         $this->online $online;
  187.         return $this;
  188.     }
  189.     public function getViews(): ?int
  190.     {
  191.         return $this->views;
  192.     }
  193.     public function setViews(int $views): self
  194.     {
  195.         $this->views $views;
  196.         return $this;
  197.     }
  198.     /**
  199.      * @return File|null
  200.      */
  201.     public function getImageFile(): ?File
  202.     {
  203.         return $this->imageFile;
  204.     }
  205.     /**
  206.      * @param File|null $imageFile
  207.      * @return Posts
  208.      * @throws Exception
  209.      */
  210.     public function setImageFile(?File $imageFile): Posts
  211.     {
  212.         $this->imageFile $imageFile;
  213.         if ($this->imageFile instanceof UploadedFile) {
  214.             // It is required that at least one field changes if you are using doctrine
  215.             // otherwise the event listeners won't be called and the file is lost
  216.             $this->updatedAt = new DateTimeImmutable('now');
  217.         }
  218.         return $this;
  219.     }
  220.     public function getFilename(): ?string
  221.     {
  222.         return $this->filename;
  223.     }
  224.     public function setFilename(?string $filename): self
  225.     {
  226.         $this->filename $filename;
  227.         return $this;
  228.     }
  229.     public function getUser(): ?User
  230.     {
  231.         return $this->user;
  232.     }
  233.     public function setUser(?User $user): self
  234.     {
  235.         $this->user $user;
  236.         return $this;
  237.     }
  238.     public function getUpdatedBy(): ?User
  239.     {
  240.         return $this->updatedBy;
  241.     }
  242.     public function setUpdatedBy(?User $updatedBy): self
  243.     {
  244.         $this->updatedBy $updatedBy;
  245.         return $this;
  246.     }
  247.     public function getCategories(): ?Categorieposts
  248.     {
  249.         return $this->categories;
  250.     }
  251.     public function setCategories(?Categorieposts $categories): self
  252.     {
  253.         $this->categories $categories;
  254.         return $this;
  255.     }
  256.     /**
  257.      * @return Collection|Mediaposts[]
  258.      */
  259.     public function getMediaposts(): Collection
  260.     {
  261.         return $this->mediaposts;
  262.     }
  263.     public function addMediapost(Mediaposts $mediaposts): self
  264.     {
  265.         if (!$this->mediaposts->contains($mediaposts)) {
  266.             $this->mediaposts[] = $mediaposts;
  267.             $mediaposts->setPosts($this);
  268.         }
  269.         return $this;
  270.     }
  271.     public function removeMediapost(Mediaposts $mediaposts): self
  272.     {
  273.         if ($this->mediaposts->contains($mediaposts)) {
  274.             $this->mediaposts->removeElement($mediaposts);
  275.             // set the owning side to null (unless already changed)
  276.             if ($mediaposts->getPosts() === $this) {
  277.                 $mediaposts->setPosts(null);
  278.             }
  279.         }
  280.         return $this;
  281.     }
  282.     /**
  283.      * @return File|null
  284.      */
  285.     public function getImageBandeauFile(): ?File
  286.     {
  287.         return $this->imageBandeauFile;
  288.     }
  289.     /**
  290.      * @param File|null $imageBandeauFile
  291.      * @return Posts
  292.      */
  293.     public function setImageBandeauFile(?File $imageBandeauFile): Posts
  294.     {
  295.         $this->imageBandeauFile $imageBandeauFile;
  296.         if ($this->imageBandeauFile instanceof UploadedFile) {
  297.             // It is required that at least one field changes if you are using doctrine
  298.             // otherwise the event listeners won't be called and the file is lost
  299.             $this->updatedAt = new DateTimeImmutable('now');
  300.         }
  301.         return $this;
  302.     }
  303.     public function getBandeaufile(): ?string
  304.     {
  305.         return $this->bandeaufile;
  306.     }
  307.     public function setBandeaufile(?string $bandeaufile): self
  308.     {
  309.         $this->bandeaufile $bandeaufile;
  310.         return $this;
  311.     }
  312.     public function getEmail(): ?string
  313.     {
  314.         return $this->email;
  315.     }
  316.     public function setEmail(?string $email): self
  317.     {
  318.         $this->email $email;
  319.         return $this;
  320.     }
  321.     public function getTelephone(): ?string
  322.     {
  323.         return $this->telephone;
  324.     }
  325.     public function setTelephone(?string $telephone): self
  326.     {
  327.         $this->telephone $telephone;
  328.         return $this;
  329.     }
  330.     public function getLieu(): ?string
  331.     {
  332.         return $this->lieu;
  333.     }
  334.     public function setLieu(?string $lieu): self
  335.     {
  336.         $this->lieu $lieu;
  337.         return $this;
  338.     }
  339.     public function getHeuredetravail(): ?string
  340.     {
  341.         return $this->heuredetravail;
  342.     }
  343.     public function setHeuredetravail(?string $heuredetravail): self
  344.     {
  345.         $this->heuredetravail $heuredetravail;
  346.         return $this;
  347.     }
  348.     public function getSiteweb(): ?string
  349.     {
  350.         return $this->siteweb;
  351.     }
  352.     public function setSiteweb(?string $siteweb): self
  353.     {
  354.         $this->siteweb $siteweb;
  355.         return $this;
  356.     }
  357.     public function getFacebook(): ?string
  358.     {
  359.         return $this->facebook;
  360.     }
  361.     public function setFacebook(?string $facebook): self
  362.     {
  363.         $this->facebook $facebook;
  364.         return $this;
  365.     }
  366.     public function getTwitter(): ?string
  367.     {
  368.         return $this->twitter;
  369.     }
  370.     public function setTwitter(?string $twitter): self
  371.     {
  372.         $this->twitter $twitter;
  373.         return $this;
  374.     }
  375.     public function getInstagram(): ?string
  376.     {
  377.         return $this->instagram;
  378.     }
  379.     public function setInstagram(?string $instagram): self
  380.     {
  381.         $this->instagram $instagram;
  382.         return $this;
  383.     }
  384.     public function getReserved(): ?bool
  385.     {
  386.         return $this->reserved;
  387.     }
  388.     public function setReserved(bool $reserved): self
  389.     {
  390.         $this->reserved $reserved;
  391.         return $this;
  392.     }
  393.     public function getLongitude(): ?string
  394.     {
  395.         return $this->longitude;
  396.     }
  397.     public function setLongitude(?string $longitude): self
  398.     {
  399.         $this->longitude $longitude;
  400.         return $this;
  401.     }
  402.     public function getLatitude(): ?string
  403.     {
  404.         return $this->latitude;
  405.     }
  406.     public function setLatitude(?string $latitude): self
  407.     {
  408.         $this->latitude $latitude;
  409.         return $this;
  410.     }
  411.     public function __toString()
  412.     {
  413.         return $this->name;
  414.     }
  415.     public function getFeatured(): ?bool
  416.     {
  417.         return $this->featured;
  418.     }
  419.     public function setFeatured(bool $featured): self
  420.     {
  421.         $this->featured $featured;
  422.         return $this;
  423.     }
  424. }