src/Entity/Session.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SessionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassSessionRepository::class)]
  9. class Session
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  16.     private ?\DateTimeInterface $date null;
  17.     #[ORM\ManyToMany(targetEntityRecipe::class, inversedBy'sessions')]
  18.     private Collection $recipes;
  19.     public function __construct()
  20.     {
  21.         $this->recipes = new ArrayCollection();
  22.     }
  23.     public function getId(): ?int
  24.     {
  25.         return $this->id;
  26.     }
  27.     public function getDate(): ?\DateTimeInterface
  28.     {
  29.         return $this->date;
  30.     }
  31.     public function setDate(\DateTimeInterface $date): self
  32.     {
  33.         $this->date $date;
  34.         return $this;
  35.     }
  36.     /**
  37.      * @return Collection<int, Recipe>
  38.      */
  39.     public function getRecipes(): Collection
  40.     {
  41.         return $this->recipes;
  42.     }
  43.     public function addRecipe(Recipe $recipe): self
  44.     {
  45.         if (!$this->recipes->contains($recipe)) {
  46.             $this->recipes->add($recipe);
  47.         }
  48.         return $this;
  49.     }
  50.     public function removeRecipe(Recipe $recipe): self
  51.     {
  52.         $this->recipes->removeElement($recipe);
  53.         return $this;
  54.     }
  55. }