src/Entity/Recipe/RecipeType.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Recipe;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Recipe\RecipeTypeRepository;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ORM\Entity(repositoryClass=RecipeTypeRepository::class)
  10.  * @ApiResource(
  11.  *     attributes={
  12.  *          "normalization_context"={"groups"={
  13.  *              "Recipe:io",
  14.  *          }},
  15.  *          "denormalization_context"={"groups"={
  16.  *              "Recipe:io",
  17.  *          }}
  18.  *      },
  19.  *     collectionOperations={
  20.  *          "public-get-recipe-types"={
  21.  *              "path"="/public/recipe_types",
  22.  *              "method"="GET",
  23.  *          },
  24.  *     },
  25.  * ),
  26.  */
  27. class RecipeType
  28. {
  29.     /**
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue
  32.      * @ORM\Column(type="integer")
  33.      * @Groups({
  34.      *     "Recipe:io",
  35.      * })
  36.      */
  37.     private $id;
  38.     /**
  39.      * @ORM\Column(type="string", length=255)
  40.      * @Groups({
  41.      *     "Recipe:io",
  42.      * })
  43.      */
  44.     private $name;
  45.     /**
  46.      * @ORM\ManyToMany(targetEntity=Recipe::class, mappedBy="recipeType")
  47.      */
  48.     private Collection $recipes;
  49.     /**
  50.      * @return Collection
  51.      */
  52.     public function getRecipes(): Collection
  53.     {
  54.         return $this->recipes;
  55.     }
  56.     /**
  57.      * @param Collection $recipes
  58.      * @return RecipeType
  59.      */
  60.     public function setRecipes(Collection $recipes): RecipeType
  61.     {
  62.         $this->recipes $recipes;
  63.         return $this;
  64.     }
  65.     public function getId(): ?int
  66.     {
  67.         return $this->id;
  68.     }
  69.     public function getName(): ?string
  70.     {
  71.         return $this->name;
  72.     }
  73.     public function setName(string $name): self
  74.     {
  75.         $this->name $name;
  76.         return $this;
  77.     }
  78.     public function __toString()
  79.     {
  80.         return $this->name;
  81.     }
  82. }