src/Domain/Entity/Post.php line 17

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\Domain\Entity;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * Class Post.
  9.  *
  10.  * @ORM\Entity(repositoryClass="App\Domain\Repository\PostRepository")
  11.  * @ORM\Table(name="post_tracol")
  12.  */
  13. class Post extends AbstractEntity
  14. {
  15.     /**
  16.      *
  17.      * @ORM\Column(type="string")
  18.      * @Assert\NotBlank(message="Veuillez renseigner les champs vides")
  19.      */
  20.     public string $name;
  21.     /**
  22.      *
  23.      * @ORM\Column(type="text")
  24.      * @Assert\NotBlank(message="Veuillez renseigner les champs vides")
  25.      */
  26.     protected string $content;
  27.     /**
  28.      *
  29.      * @ORM\ManyToMany(targetEntity="App\Domain\Entity\Picture", cascade={"remove"}, cascade={"persist"},  orphanRemoval=true)
  30.      * @ORM\JoinTable(name="post_pictures",
  31.      *     joinColumns={@ORM\JoinColumn(referencedColumnName="id", name="post_id")},
  32.      *     inverseJoinColumns={@ORM\JoinColumn(referencedColumnName="id", name="picture_id")}
  33.      *     )
  34.      */
  35.     protected $picture;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="App\Domain\Entity\Tag", cascade={"persist"})
  38.      */
  39.     protected Tag $tag;
  40.     public function __construct(
  41.     ) {
  42.         $this->picture = new ArrayCollection();
  43.         $this->createdAt time();
  44.         parent::__construct();
  45.     }
  46.     public function getName(): string
  47.     {
  48.         return $this->name;
  49.     }
  50.     public function setName(string $name): Post
  51.     {
  52.         $this->name $name;
  53.         return $this;
  54.     }
  55.     public function getContent(): string
  56.     {
  57.         return $this->content;
  58.     }
  59.     public function setContent(string $content): Post
  60.     {
  61.         $this->content $content;
  62.         return $this;
  63.     }
  64.     public function getPicture()
  65.     {
  66.         return $this->picture;
  67.     }
  68.     public function setPicture($picture): Post
  69.     {
  70.         $this->picture $picture;
  71.         return $this;
  72.     }
  73.     public function getTag(): Tag
  74.     {
  75.         return $this->tag;
  76.     }
  77.     public function setTag(Tag $tag): Post
  78.     {
  79.         $this->tag $tag;
  80.         return $this;
  81.     }
  82. }