src/Entity/BookMaker.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BookMakerRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. #[ORM\Entity(repositoryClassBookMakerRepository::class)]
  9. class BookMaker
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'bookMakers')]
  16.     #[Groups(["show_recipe"])]
  17.     private Collection $saver;
  18.     #[ORM\ManyToMany(targetEntityRecipe::class, inversedBy'bookMakers')]
  19.     #[Groups("user_info")]
  20.     private Collection $recipe;
  21.     public function __construct()
  22.     {
  23.         $this->saver = new ArrayCollection();
  24.         $this->recipe = new ArrayCollection();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     /**
  31.      * @return Collection<int, User>
  32.      */
  33.     public function getSaver(): Collection
  34.     {
  35.         return $this->saver;
  36.     }
  37.     public function addSaver(User $saver): self
  38.     {
  39.         if (!$this->saver->contains($saver)) {
  40.             $this->saver->add($saver);
  41.         }
  42.         return $this;
  43.     }
  44.     public function removeSaver(User $saver): self
  45.     {
  46.         $this->saver->removeElement($saver);
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Recipe>
  51.      */
  52.     public function getRecipe(): Collection
  53.     {
  54.         return $this->recipe;
  55.     }
  56.     public function addRecipe(Recipe $recipe): self
  57.     {
  58.         if (!$this->recipe->contains($recipe)) {
  59.             $this->recipe->add($recipe);
  60.         }
  61.         return $this;
  62.     }
  63.     public function removeRecipe(Recipe $recipe): self
  64.     {
  65.         $this->recipe->removeElement($recipe);
  66.         return $this;
  67.     }
  68. }