<?php
namespace App\Entity\Recipe;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\Recipe\RecipeTypeRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=RecipeTypeRepository::class)
* @ApiResource(
* attributes={
* "normalization_context"={"groups"={
* "Recipe:io",
* }},
* "denormalization_context"={"groups"={
* "Recipe:io",
* }}
* },
* collectionOperations={
* "public-get-recipe-types"={
* "path"="/public/recipe_types",
* "method"="GET",
* },
* },
* ),
*/
class RecipeType
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "Recipe:io",
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "Recipe:io",
* })
*/
private $name;
/**
* @ORM\ManyToMany(targetEntity=Recipe::class, mappedBy="recipeType")
*/
private Collection $recipes;
/**
* @return Collection
*/
public function getRecipes(): Collection
{
return $this->recipes;
}
/**
* @param Collection $recipes
* @return RecipeType
*/
public function setRecipes(Collection $recipes): RecipeType
{
$this->recipes = $recipes;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function __toString()
{
return $this->name;
}
}