Loading src/Entity/Gallery.php +24 −18 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ namespace App\Entity; use App\Repository\GalleryRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Uid\Uuid; Loading @@ -14,39 +16,43 @@ class Gallery #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; #[ORM\ManyToOne(inversedBy: 'galleries')] #[ORM\JoinColumn(nullable: false)] private ?Restaurant $restaurant = null; /** * @var Collection<int, File> */ #[ORM\ManyToMany(targetEntity: File::class)] private Collection $files; #[ORM\OneToOne(cascade: ['persist', 'remove'])] #[ORM\JoinColumn(nullable: false)] private ?File $file = null; public function __construct() { $this->files = new ArrayCollection(); } public function getId(): ?int public function getId(): ?Uuid { return $this->id; } public function getRestaurant(): ?Restaurant /** * @return Collection<int, File> */ public function getFile(): Collection { return $this->restaurant; return $this->files; } public function setRestaurant(?Restaurant $restaurant): static public function addFile(File $file): static { $this->restaurant = $restaurant; return $this; if (!$this->files->contains($file)) { $this->files->add($file); } public function getFile(): ?File { return $this->file; return $this; } public function setFile(File $file): static public function removeFile(File $file): static { $this->file = $file; $this->files->removeElement($file); return $this; } Loading Loading
src/Entity/Gallery.php +24 −18 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ namespace App\Entity; use App\Repository\GalleryRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Uid\Uuid; Loading @@ -14,39 +16,43 @@ class Gallery #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; #[ORM\ManyToOne(inversedBy: 'galleries')] #[ORM\JoinColumn(nullable: false)] private ?Restaurant $restaurant = null; /** * @var Collection<int, File> */ #[ORM\ManyToMany(targetEntity: File::class)] private Collection $files; #[ORM\OneToOne(cascade: ['persist', 'remove'])] #[ORM\JoinColumn(nullable: false)] private ?File $file = null; public function __construct() { $this->files = new ArrayCollection(); } public function getId(): ?int public function getId(): ?Uuid { return $this->id; } public function getRestaurant(): ?Restaurant /** * @return Collection<int, File> */ public function getFile(): Collection { return $this->restaurant; return $this->files; } public function setRestaurant(?Restaurant $restaurant): static public function addFile(File $file): static { $this->restaurant = $restaurant; return $this; if (!$this->files->contains($file)) { $this->files->add($file); } public function getFile(): ?File { return $this->file; return $this; } public function setFile(File $file): static public function removeFile(File $file): static { $this->file = $file; $this->files->removeElement($file); return $this; } Loading