src/Entity/Family.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Repository\FamilyRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. /**
  11.  * @ORM\Entity(repositoryClass=FamilyRepository::class)
  12.  * @ApiResource(
  13.  *     collectionOperations={"get","post"},
  14.  *     itemOperations={"get","put","patch","delete"},
  15.  *     normalizationContext={"groups"={"family"}},
  16.  *     denormalizationContext={"groups"={"family"}},
  17.  *     attributes={"pagination_enabled"=false}
  18.  * )
  19.  */
  20. class Family
  21. {
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      * @Groups("family", "article")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      * @Groups("family")
  32.      */
  33.     private $nameFr;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      * @Groups("family")
  37.      */
  38.     private $nameEn;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      * @Groups("family")
  42.      */
  43.     private $nameDe;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      * @Groups("family")
  47.      */
  48.     private $nameNl;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity=Article::class, mappedBy="family")
  51.      */
  52.     private $articles;
  53.     /**
  54.      * @ORM\Column(type="text", nullable=true)
  55.      * @Groups("family")
  56.      */
  57.     private $image;
  58.     public function __construct()
  59.     {
  60.         $this->articles = new ArrayCollection();
  61.     }
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getNameFr(): ?string
  67.     {
  68.         return $this->nameFr;
  69.     }
  70.     public function setNameFr(?string $nameFr): self
  71.     {
  72.         $this->nameFr $nameFr;
  73.         return $this;
  74.     }
  75.     public function getNameEn(): ?string
  76.     {
  77.         return $this->nameEn;
  78.     }
  79.     public function setNameEn(?string $nameEn): self
  80.     {
  81.         $this->nameEn $nameEn;
  82.         return $this;
  83.     }
  84.     public function getNameDe(): ?string
  85.     {
  86.         return $this->nameDe;
  87.     }
  88.     public function setNameDe(?string $nameDe): self
  89.     {
  90.         $this->nameDe $nameDe;
  91.         return $this;
  92.     }
  93.     public function getNameNl(): ?string
  94.     {
  95.         return $this->nameNl;
  96.     }
  97.     public function setNameNl(?string $nameNl): self
  98.     {
  99.         $this->nameNl $nameNl;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return Collection|Article[]
  104.      */
  105.     public function getArticles(): Collection
  106.     {
  107.         return $this->articles;
  108.     }
  109.     public function addArticle(Article $article): self
  110.     {
  111.         if (!$this->articles->contains($article)) {
  112.             $this->articles[] = $article;
  113.             $article->setFamily($this);
  114.         }
  115.         return $this;
  116.     }
  117.     public function removeArticle(Article $article): self
  118.     {
  119.         if ($this->articles->removeElement($article)) {
  120.             // set the owning side to null (unless already changed)
  121.             if ($article->getFamily() === $this) {
  122.                 $article->setFamily(null);
  123.             }
  124.         }
  125.         return $this;
  126.     }
  127.     public function getImage(): ?string
  128.     {
  129.         return $this->image;
  130.     }
  131.     public function setImage(?string $image): self
  132.     {
  133.         $this->image $image;
  134.         return $this;
  135.     }
  136. }