From b1b45cc944d75dfec3e1f5fe00d51c646be6d4aa Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Thu, 2 May 2024 14:50:18 +0500 Subject: [PATCH] =?UTF-8?q?STA-965=20|=20=D0=9F=D0=BE=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20uuid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...02075531.php => Version20240502094853.php} | 36 ++++++++----- src/Entity/File.php | 14 ++--- src/Entity/Gallery.php | 44 ++++++++-------- src/Entity/Kitchen.php | 6 ++- src/Entity/News.php | 10 ++-- src/Entity/NewsCategory.php | 6 ++- src/Entity/NewsComment.php | 6 ++- src/Entity/NewsType.php | 10 ++-- src/Entity/Restaurant.php | 51 +++---------------- src/Entity/RestaurantType.php | 10 ++-- src/Entity/Seo.php | 6 ++- src/Entity/Settlement.php | 10 ++-- src/Entity/Tags.php | 6 ++- src/Entity/User.php | 13 +++-- 14 files changed, 107 insertions(+), 121 deletions(-) rename migrations/{Version20240502075531.php => Version20240502094853.php} (83%) diff --git a/migrations/Version20240502075531.php b/migrations/Version20240502094853.php similarity index 83% rename from migrations/Version20240502075531.php rename to migrations/Version20240502094853.php index 0a37630..1727aac 100644 --- a/migrations/Version20240502075531.php +++ b/migrations/Version20240502094853.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20240502075531 extends AbstractMigration +final class Version20240502094853 extends AbstractMigration { public function getDescription(): string { @@ -20,24 +20,28 @@ final class Version20240502075531 extends AbstractMigration public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SEQUENCE gallery_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE SEQUENCE seo_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('DROP SEQUENCE gallery_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE seo_id_seq CASCADE'); $this->addSql('CREATE TABLE file (id UUID NOT NULL, name VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, size INT NOT NULL, type VARCHAR(255) NOT NULL, url VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); $this->addSql('COMMENT ON COLUMN file.id IS \'(DC2Type:uuid)\''); - $this->addSql('CREATE TABLE gallery (id INT NOT NULL, restaurant_id UUID NOT NULL, file_id UUID NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX IDX_472B783AB1E7706E ON gallery (restaurant_id)'); + $this->addSql('CREATE TABLE gallery (id UUID NOT NULL, restaurant_id UUID NOT NULL, file_id UUID NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_472B783AB1E7706E ON gallery (restaurant_id)'); $this->addSql('CREATE UNIQUE INDEX UNIQ_472B783A93CB796C ON gallery (file_id)'); + $this->addSql('COMMENT ON COLUMN gallery.id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN gallery.restaurant_id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN gallery.file_id IS \'(DC2Type:uuid)\''); $this->addSql('CREATE TABLE kitchen (id UUID NOT NULL, restaurant_id UUID NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_EAA3CE34B1E7706E ON kitchen (restaurant_id)'); $this->addSql('COMMENT ON COLUMN kitchen.id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN kitchen.restaurant_id IS \'(DC2Type:uuid)\''); - $this->addSql('CREATE TABLE news (id UUID NOT NULL, type_id UUID NOT NULL, seo_id INT NOT NULL, code VARCHAR(255) NOT NULL, active BOOLEAN NOT NULL, create_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, sort INT NOT NULL, preview_image VARCHAR(255) NOT NULL, detail_image VARCHAR(255) NOT NULL, preview_text TEXT NOT NULL, detail_text TEXT NOT NULL, main_page_render BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE news (id UUID NOT NULL, type_id UUID NOT NULL, seo_id UUID NOT NULL, file_id UUID NOT NULL, code VARCHAR(255) NOT NULL, active BOOLEAN NOT NULL, create_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, sort INT NOT NULL, preview_image VARCHAR(255) NOT NULL, detail_image VARCHAR(255) NOT NULL, preview_text TEXT NOT NULL, detail_text TEXT NOT NULL, main_page_render BOOLEAN NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_1DD39950C54C8C93 ON news (type_id)'); $this->addSql('CREATE INDEX IDX_1DD3995097E3DD86 ON news (seo_id)'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_1DD3995093CB796C ON news (file_id)'); $this->addSql('COMMENT ON COLUMN news.id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN news.type_id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN news.seo_id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN news.file_id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN news.create_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('COMMENT ON COLUMN news.update_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('CREATE TABLE news_news_category (news_id UUID NOT NULL, news_category_id UUID NOT NULL, PRIMARY KEY(news_id, news_category_id))'); @@ -59,19 +63,23 @@ final class Version20240502075531 extends AbstractMigration $this->addSql('COMMENT ON COLUMN news_comment.update_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('CREATE TABLE news_type (id UUID NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); $this->addSql('COMMENT ON COLUMN news_type.id IS \'(DC2Type:uuid)\''); - $this->addSql('CREATE TABLE restaurant (id UUID NOT NULL, type_id_id UUID NOT NULL, settlement_id_id UUID NOT NULL, seo_id INT NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, active BOOLEAN NOT NULL, sort INT NOT NULL, create_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, coordinates TEXT NOT NULL, description TEXT NOT NULL, check_price VARCHAR(255) NOT NULL, check_info TEXT NOT NULL, phone JSON NOT NULL, email JSON NOT NULL, address JSON NOT NULL, site VARCHAR(255) NOT NULL, preview_image VARCHAR(255) NOT NULL, detail_image VARCHAR(255) NOT NULL, how_to_find TEXT NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE restaurant (id UUID NOT NULL, type_id_id UUID NOT NULL, settlement_id_id UUID NOT NULL, seo_id UUID NOT NULL, file_id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, active BOOLEAN NOT NULL, sort INT NOT NULL, create_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, coordinates TEXT NOT NULL, description TEXT NOT NULL, check_price VARCHAR(255) NOT NULL, check_info TEXT NOT NULL, phone JSON NOT NULL, email JSON NOT NULL, address JSON NOT NULL, site VARCHAR(255) NOT NULL, preview_image VARCHAR(255) NOT NULL, detail_image VARCHAR(255) NOT NULL, how_to_find TEXT NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_EB95123F714819A0 ON restaurant (type_id_id)'); $this->addSql('CREATE INDEX IDX_EB95123F45EC589B ON restaurant (settlement_id_id)'); $this->addSql('CREATE INDEX IDX_EB95123F97E3DD86 ON restaurant (seo_id)'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_EB95123F93CB796C ON restaurant (file_id)'); $this->addSql('COMMENT ON COLUMN restaurant.id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN restaurant.type_id_id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN restaurant.settlement_id_id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN restaurant.seo_id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN restaurant.file_id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN restaurant.create_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('COMMENT ON COLUMN restaurant.update_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('COMMENT ON COLUMN restaurant.coordinates IS \'(DC2Type:simple_array)\''); $this->addSql('CREATE TABLE restaurant_type (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); $this->addSql('COMMENT ON COLUMN restaurant_type.id IS \'(DC2Type:uuid)\''); - $this->addSql('CREATE TABLE seo (id INT NOT NULL, title VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, keywords VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE seo (id UUID NOT NULL, title VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, keywords VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('COMMENT ON COLUMN seo.id IS \'(DC2Type:uuid)\''); $this->addSql('CREATE TABLE settlement (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, coordinates TEXT NOT NULL, create_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))'); $this->addSql('COMMENT ON COLUMN settlement.id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN settlement.coordinates IS \'(DC2Type:array)\''); @@ -82,10 +90,8 @@ final class Version20240502075531 extends AbstractMigration $this->addSql('COMMENT ON COLUMN tags.id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN tags.restaurant_id IS \'(DC2Type:uuid)\''); $this->addSql('COMMENT ON COLUMN tags.list IS \'(DC2Type:simple_array)\''); - $this->addSql('CREATE TABLE "user" (id UUID NOT NULL, uuid UUID NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649D17F50A6 ON "user" (uuid)'); + $this->addSql('CREATE TABLE "user" (id UUID NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); $this->addSql('COMMENT ON COLUMN "user".id IS \'(DC2Type:uuid)\''); - $this->addSql('COMMENT ON COLUMN "user".uuid IS \'(DC2Type:uuid)\''); $this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)'); $this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)'); @@ -106,6 +112,7 @@ final class Version20240502075531 extends AbstractMigration $this->addSql('ALTER TABLE kitchen ADD CONSTRAINT FK_EAA3CE34B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD39950C54C8C93 FOREIGN KEY (type_id) REFERENCES news_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD3995097E3DD86 FOREIGN KEY (seo_id) REFERENCES seo (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD3995093CB796C FOREIGN KEY (file_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE news_news_category ADD CONSTRAINT FK_1A91D6D6B5A459A0 FOREIGN KEY (news_id) REFERENCES news (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE news_news_category ADD CONSTRAINT FK_1A91D6D63B732BAD FOREIGN KEY (news_category_id) REFERENCES news_category (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8A5FB1909 FOREIGN KEY (news_id_id) REFERENCES news (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); @@ -114,6 +121,7 @@ final class Version20240502075531 extends AbstractMigration $this->addSql('ALTER TABLE restaurant ADD CONSTRAINT FK_EB95123F714819A0 FOREIGN KEY (type_id_id) REFERENCES restaurant_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE restaurant ADD CONSTRAINT FK_EB95123F45EC589B FOREIGN KEY (settlement_id_id) REFERENCES settlement (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE restaurant ADD CONSTRAINT FK_EB95123F97E3DD86 FOREIGN KEY (seo_id) REFERENCES seo (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE restaurant ADD CONSTRAINT FK_EB95123F93CB796C FOREIGN KEY (file_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE tags ADD CONSTRAINT FK_6FBC9426B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); } @@ -121,13 +129,14 @@ final class Version20240502075531 extends AbstractMigration { // this down() migration is auto-generated, please modify it to your needs $this->addSql('CREATE SCHEMA public'); - $this->addSql('DROP SEQUENCE gallery_id_seq CASCADE'); - $this->addSql('DROP SEQUENCE seo_id_seq CASCADE'); + $this->addSql('CREATE SEQUENCE gallery_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE seo_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('ALTER TABLE gallery DROP CONSTRAINT FK_472B783AB1E7706E'); $this->addSql('ALTER TABLE gallery DROP CONSTRAINT FK_472B783A93CB796C'); $this->addSql('ALTER TABLE kitchen DROP CONSTRAINT FK_EAA3CE34B1E7706E'); $this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD39950C54C8C93'); $this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD3995097E3DD86'); + $this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD3995093CB796C'); $this->addSql('ALTER TABLE news_news_category DROP CONSTRAINT FK_1A91D6D6B5A459A0'); $this->addSql('ALTER TABLE news_news_category DROP CONSTRAINT FK_1A91D6D63B732BAD'); $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8A5FB1909'); @@ -136,6 +145,7 @@ final class Version20240502075531 extends AbstractMigration $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F714819A0'); $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F45EC589B'); $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F97E3DD86'); + $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F93CB796C'); $this->addSql('ALTER TABLE tags DROP CONSTRAINT FK_6FBC9426B1E7706E'); $this->addSql('DROP TABLE file'); $this->addSql('DROP TABLE gallery'); diff --git a/src/Entity/File.php b/src/Entity/File.php index 712eb87..cb72c42 100644 --- a/src/Entity/File.php +++ b/src/Entity/File.php @@ -3,15 +3,18 @@ namespace App\Entity; use App\Repository\FileRepository; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: FileRepository::class)] class File { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] @@ -34,13 +37,6 @@ class File return $this->id; } - public function setId(Uuid $id): static - { - $this->id = $id; - - return $this; - } - public function getName(): ?string { return $this->name; diff --git a/src/Entity/Gallery.php b/src/Entity/Gallery.php index 7f1c5f3..c2def04 100644 --- a/src/Entity/Gallery.php +++ b/src/Entity/Gallery.php @@ -6,53 +6,51 @@ use App\Repository\GalleryRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: GalleryRepository::class)] class Gallery { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; - /** - * @var Collection - */ - #[ORM\ManyToMany(targetEntity: File::class)] - private Collection $files; - - public function __construct() - { - $this->files = new ArrayCollection(); - } + #[ORM\OneToOne(cascade: ['persist', 'remove'])] + #[ORM\JoinColumn(nullable: false)] + private ?Restaurant $restaurant = null; + #[ORM\OneToOne(cascade: ['persist', 'remove'])] + #[ORM\JoinColumn(nullable: false)] + private ?File $file = null; public function getId(): ?Uuid { return $this->id; } - /** - * @return Collection - */ - public function getFile(): Collection + public function getRestaurant(): ?Restaurant { - return $this->files; + return $this->restaurant; } - public function addFile(File $file): static + public function setRestaurant(Restaurant $restaurant): static { - if (!$this->files->contains($file)) { - $this->files->add($file); - } + $this->restaurant = $restaurant; return $this; } - public function removeFile(File $file): static + public function getFile(): ?File + { + return $this->file; + } + + public function setFile(File $file): static { - $this->files->removeElement($file); + $this->file = $file; return $this; } diff --git a/src/Entity/Kitchen.php b/src/Entity/Kitchen.php index 91a71a3..1d9fbbc 100644 --- a/src/Entity/Kitchen.php +++ b/src/Entity/Kitchen.php @@ -4,14 +4,16 @@ namespace App\Entity; use App\Repository\KitchenRepository; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: KitchenRepository::class)] class Kitchen { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] diff --git a/src/Entity/News.php b/src/Entity/News.php index 899f569..296d6be 100644 --- a/src/Entity/News.php +++ b/src/Entity/News.php @@ -7,14 +7,16 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: NewsRepository::class)] class News { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] @@ -52,7 +54,7 @@ class News private ?bool $mainPageRender = null; /** - * @var Collection + * @var Collection */ #[ORM\ManyToMany(targetEntity: NewsCategory::class)] private Collection $newsCategories; @@ -208,7 +210,7 @@ class News } /** - * @return Collection + * @return Collection */ public function getNewsCategories(): Collection { diff --git a/src/Entity/NewsCategory.php b/src/Entity/NewsCategory.php index 7fbe56b..96ace33 100644 --- a/src/Entity/NewsCategory.php +++ b/src/Entity/NewsCategory.php @@ -6,14 +6,16 @@ use App\Repository\NewsCategoryRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: NewsCategoryRepository::class)] class NewsCategory { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] diff --git a/src/Entity/NewsComment.php b/src/Entity/NewsComment.php index 46c066d..c4f2ed0 100644 --- a/src/Entity/NewsComment.php +++ b/src/Entity/NewsComment.php @@ -5,14 +5,16 @@ namespace App\Entity; use App\Repository\NewsCommentRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: NewsCommentRepository::class)] class NewsComment { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\OneToOne(cascade: ['persist', 'remove'])] diff --git a/src/Entity/NewsType.php b/src/Entity/NewsType.php index abd94e1..bd3fbd1 100644 --- a/src/Entity/NewsType.php +++ b/src/Entity/NewsType.php @@ -6,21 +6,23 @@ use App\Repository\NewsTypeRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: NewsTypeRepository::class)] class NewsType { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] private ?string $name = null; /** - * @var Collection + * @var Collection */ #[ORM\OneToMany(targetEntity: News::class, mappedBy: 'type')] private Collection $news; @@ -48,7 +50,7 @@ class NewsType } /** - * @return Collection + * @return Collection */ public function getNews(): Collection { diff --git a/src/Entity/Restaurant.php b/src/Entity/Restaurant.php index 37d2318..b7b252c 100644 --- a/src/Entity/Restaurant.php +++ b/src/Entity/Restaurant.php @@ -7,14 +7,16 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: RestaurantRepository::class)] class Restaurant { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] @@ -56,7 +58,7 @@ class Restaurant private ?string $checkInfo = null; /** - * @var Collection + * @var Collection */ #[ORM\OneToMany(targetEntity: Kitchen::class, mappedBy: 'restaurant')] private Collection $kitchen; @@ -71,7 +73,7 @@ class Restaurant private array $address = []; /** - * @var Collection + * @var Collection */ #[ORM\OneToMany(targetEntity: Tags::class, mappedBy: 'restaurant')] private Collection $tags; @@ -88,12 +90,6 @@ class Restaurant #[ORM\Column(type: Types::TEXT)] private ?string $howToFind = null; - /** - * @var Collection - */ - #[ORM\OneToMany(targetEntity: Gallery::class, mappedBy: 'restaurant')] - private Collection $galleries; - #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?Seo $seo = null; @@ -106,7 +102,6 @@ class Restaurant { $this->kitchen = new ArrayCollection(); $this->tags = new ArrayCollection(); - $this->galleries = new ArrayCollection(); } public function getId(): ?Uuid @@ -259,7 +254,7 @@ class Restaurant } /** - * @return Collection + * @return Collection */ public function getKitchen(): Collection { @@ -289,7 +284,7 @@ class Restaurant } /** - * @return Collection + * @return Collection */ public function getTags(): Collection { @@ -366,36 +361,6 @@ class Restaurant return $this; } - /** - * @return Collection - */ - public function getGalleries(): Collection - { - return $this->galleries; - } - - public function addGallery(Gallery $gallery): static - { - if (!$this->galleries->contains($gallery)) { - $this->galleries->add($gallery); - $gallery->setRestaurant($this); - } - - return $this; - } - - public function removeGallery(Gallery $gallery): static - { - if ($this->galleries->removeElement($gallery)) { - // set the owning side to null (unless already changed) - if ($gallery->getRestaurant() === $this) { - $gallery->setRestaurant(null); - } - } - - return $this; - } - public function getSeo(): ?Seo { return $this->seo; diff --git a/src/Entity/RestaurantType.php b/src/Entity/RestaurantType.php index 447b0ee..2708f85 100644 --- a/src/Entity/RestaurantType.php +++ b/src/Entity/RestaurantType.php @@ -6,14 +6,16 @@ use App\Repository\RestaurantTypeRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: RestaurantTypeRepository::class)] class RestaurantType { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] @@ -23,7 +25,7 @@ class RestaurantType private ?string $code = null; /** - * @var Collection + * @var Collection */ #[ORM\OneToMany(targetEntity: Restaurant::class, mappedBy: 'typeId')] private Collection $restaurants; @@ -63,7 +65,7 @@ class RestaurantType } /** - * @return Collection + * @return Collection */ public function getRestaurants(): Collection { diff --git a/src/Entity/Seo.php b/src/Entity/Seo.php index 59d2140..3cd6f55 100644 --- a/src/Entity/Seo.php +++ b/src/Entity/Seo.php @@ -4,14 +4,16 @@ namespace App\Entity; use App\Repository\SeoRepository; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: SeoRepository::class)] class Seo { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] diff --git a/src/Entity/Settlement.php b/src/Entity/Settlement.php index b6cb733..3254477 100644 --- a/src/Entity/Settlement.php +++ b/src/Entity/Settlement.php @@ -7,14 +7,16 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: SettlementRepository::class)] class Settlement { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] @@ -33,7 +35,7 @@ class Settlement private ?\DateTimeInterface $updateAt = null; /** - * @var Collection + * @var Collection */ #[ORM\OneToMany(targetEntity: Restaurant::class, mappedBy: 'settlementId')] private Collection $restaurants; @@ -109,7 +111,7 @@ class Settlement } /** - * @return Collection + * @return Collection */ public function getRestaurants(): Collection { diff --git a/src/Entity/Tags.php b/src/Entity/Tags.php index 03c7186..87fc08c 100644 --- a/src/Entity/Tags.php +++ b/src/Entity/Tags.php @@ -5,14 +5,16 @@ namespace App\Entity; use App\Repository\TagsRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: TagsRepository::class)] class Tags { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; #[ORM\Column(length: 255)] diff --git a/src/Entity/User.php b/src/Entity/User.php index 1939b59..629c248 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -6,6 +6,7 @@ use App\Repository\UserRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: UserRepository::class)] @@ -13,18 +14,16 @@ use Symfony\Component\Uid\Uuid; class User { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: 'uuid', unique: true)] + #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id = null; - #[ORM\Column(type: 'uuid', unique: true)] - private ?Uuid $uuid = null; - #[ORM\Column(length: 255)] private ?string $name = null; /** - * @var Collection + * @var Collection */ #[ORM\OneToMany(targetEntity: NewsComment::class, mappedBy: 'userId')] private Collection $newsComments; @@ -52,7 +51,7 @@ class User } /** - * @return Collection + * @return Collection */ public function getNewsComments(): Collection { -- GitLab