<?phpnamespace App\Entity;use App\Entity\Eventable\EventableTrait;use App\Entity\Sortable\Sortable;use App\Entity\Sortable\SortableInterface;use App\Repository\FoodRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Uid\Uuid;/** * @ORM\Entity(repositoryClass=FoodRepository::class) */class Food implements SortableInterface{ use Sortable; /** * @ORM\Id * @ORM\Column(type="uuid", unique=true) */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\ManyToMany(targetEntity=Image::class, cascade={"persist", "remove"}, orphanRemoval=true) */ private $images; /** * @ORM\Column(type="text", nullable=true) */ private $description; /** * @ORM\ManyToMany(targetEntity=Event::class, inversedBy="food") */ private $events; public function __construct() { $this->id = Uuid::v4(); $this->images = new ArrayCollection(); $this->events = new ArrayCollection(); } public function getId(): string { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } /** * @return Collection<int, Image> */ public function getImages(): Collection { return $this->images; } public function addImage(Image $image): self { if (!$this->images->contains($image)) { $this->images[] = $image; } return $this; } public function removeImage(Image $image): self { $this->images->removeElement($image); return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } /** * @return Collection<int, Event> */ public function getEvents(): Collection { return $this->events; } public function addEvent(Event $event): self { if (!$this->events->contains($event)) { $this->events[] = $event; } return $this; } public function removeEvent(Event $event): self { $this->events->removeElement($event); return $this; }}