src/Entity/Fil.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClass\App\Repository\FilRepository::class)]
  7. class Fil implements \Stringable
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private int $id;
  13.     #[ORM\Column(type'string'length255nullabletrue)]
  14.     private ?string $namenull;
  15.     #[ORM\Column(type'string'length255nullabletrue)]
  16.     private ?string $kindnull;
  17.     #[ORM\ManyToMany(targetEntity\App\Entity\Post::class, mappedBy'fils')]
  18.     private mixed $posts;
  19.     public function __construct()
  20.     {
  21.         $this->posts = new ArrayCollection();
  22.     }
  23.     public function getId(): ?int
  24.     {
  25.         return $this->id;
  26.     }
  27.     public function getName(): ?string
  28.     {
  29.         return $this->name;
  30.     }
  31.     public function setName(?string $name): self
  32.     {
  33.         $this->name $name;
  34.         return $this;
  35.     }
  36.     public function getKind(): ?string
  37.     {
  38.         return $this->kind;
  39.     }
  40.     public function setKind(?string $kind): self
  41.     {
  42.         $this->kind $kind;
  43.         return $this;
  44.     }
  45.     public function __toString(): string
  46.     {
  47.         return (string) $this->name;
  48.     }
  49.     /**
  50.      * @return Collection|Post[]
  51.      */
  52.     public function getPosts(): Collection
  53.     {
  54.         return $this->posts;
  55.     }
  56.     public function addPost(Post $post): self
  57.     {
  58.         if (!$this->posts->contains($post)) {
  59.             $this->posts[] = $post;
  60.             $post->addFil($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removePost(Post $post): self
  65.     {
  66.         if ($this->posts->contains($post)) {
  67.             $this->posts->removeElement($post);
  68.             $post->removeFil($this);
  69.         }
  70.         return $this;
  71.     }
  72. }