src/Entity/Recipe/RecipeIngredient.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Recipe;
  3. use App\Repository\Recipe\RecipeIngredientRepository;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. /**
  8.  * @ApiResource(
  9.  *     attributes={
  10.  *         "order"={"position": "ASC"}
  11.  *     },
  12.  * )
  13.  *
  14.  * @ORM\Entity(repositoryClass=RecipeIngredientRepository::class)
  15.  */
  16. class RecipeIngredient
  17. {
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=Recipe::class, inversedBy="recipeIngredients")
  26.      * @ORM\JoinColumn(nullable=false)
  27.      */
  28.     private $recipe;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Ingredient::class, inversedBy="recipeIngredients")
  31.      * @ORM\JoinColumn(nullable=false)
  32.      * @Groups({
  33.      *     "Recipe:io",
  34.      * })
  35.      */
  36.     private $ingredient;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity=IngredientMeasureUnit::class)
  39.      * @Groups({
  40.      *     "Recipe:io",
  41.      * })
  42.      */
  43.     private $measureUnit;
  44.     /**
  45.      * @ORM\Column(type="float")
  46.      * @Groups({
  47.      *     "Recipe:io",
  48.      * })
  49.      */
  50.     private $quantity;
  51.     /**
  52.      * @ORM\Column(type="integer")
  53.      * @ORM\GeneratedValue(strategy="AUTO")
  54.      * @Groups({
  55.      *     "Recipe:io",
  56.      * })
  57.      */
  58.     private ?int $position 1;
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getRecipe(): ?Recipe
  64.     {
  65.         return $this->recipe;
  66.     }
  67.     public function setRecipe(?Recipe $recipe): self
  68.     {
  69.         $this->recipe $recipe;
  70.         return $this;
  71.     }
  72.     public function getIngredient(): ?Ingredient
  73.     {
  74.         return $this->ingredient;
  75.     }
  76.     public function setIngredient(?Ingredient $ingredient): self
  77.     {
  78.         $this->ingredient $ingredient;
  79.         return $this;
  80.     }
  81.     public function getMeasureUnit(): ?IngredientMeasureUnit
  82.     {
  83.         return $this->measureUnit;
  84.     }
  85.     public function setMeasureUnit(?IngredientMeasureUnit $measureUnit): self
  86.     {
  87.         $this->measureUnit $measureUnit;
  88.         return $this;
  89.     }
  90.     public function getQuantity(): ?float
  91.     {
  92.         return $this->quantity;
  93.     }
  94.     public function setQuantity(float $quantity): self
  95.     {
  96.         $this->quantity $quantity;
  97.         return $this;
  98.     }
  99.     public function getPosition(): ?int
  100.     {
  101.         return $this->position;
  102.     }
  103.     public function setPosition(int $position): self
  104.     {
  105.         $this->position $position;
  106.         return $this;
  107.     }
  108. }