From 2df6ce7deb298bbc3a616147a1544206f552fa8f Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Tue, 23 Apr 2024 12:19:03 +0500 Subject: [PATCH 01/11] =?UTF-8?q?STA-965=20|=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5=20=D1=81?= =?UTF-8?q?=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=B8=20=D0=BC?= =?UTF-8?q?=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- composer.json | 1 + composer.lock | 155 ++++++- migrations/Version20240423071100.php | 103 +++++ migrations/Version20240423071601.php | 40 ++ src/Entity/Address.php | 51 +++ src/Entity/Email.php | 51 +++ src/Entity/Kitchen.php | 51 +++ src/Entity/News.php | 224 ++++++++++ src/Entity/NewsCategory.php | 79 ++++ src/Entity/NewsComment.php | 144 ++++++ src/Entity/NewsType.php | 78 ++++ src/Entity/Phone.php | 51 +++ src/Entity/Restaurant.php | 470 ++++++++++++++++++++ src/Entity/RestaurantType.php | 93 ++++ src/Entity/Settlement.php | 155 +++++++ src/Entity/Tags.php | 51 +++ src/Entity/User.php | 95 ++++ src/Repository/AddressRepository.php | 48 ++ src/Repository/EmailRepository.php | 48 ++ src/Repository/KitchenRepository.php | 48 ++ src/Repository/NewsCategoryRepository.php | 48 ++ src/Repository/NewsCommentRepository.php | 48 ++ src/Repository/NewsRepository.php | 48 ++ src/Repository/NewsTypeRepository.php | 48 ++ src/Repository/PhoneRepository.php | 48 ++ src/Repository/RestaurantRepository.php | 48 ++ src/Repository/RestaurantTypeRepository.php | 48 ++ src/Repository/SettlementRepository.php | 48 ++ src/Repository/TagsRepository.php | 48 ++ src/Repository/UserRepository.php | 48 ++ symfony.lock | 9 + 32 files changed, 2525 insertions(+), 2 deletions(-) create mode 100644 migrations/Version20240423071100.php create mode 100644 migrations/Version20240423071601.php create mode 100644 src/Entity/Address.php create mode 100644 src/Entity/Email.php create mode 100644 src/Entity/Kitchen.php create mode 100644 src/Entity/News.php create mode 100644 src/Entity/NewsCategory.php create mode 100644 src/Entity/NewsComment.php create mode 100644 src/Entity/NewsType.php create mode 100644 src/Entity/Phone.php create mode 100644 src/Entity/Restaurant.php create mode 100644 src/Entity/RestaurantType.php create mode 100644 src/Entity/Settlement.php create mode 100644 src/Entity/Tags.php create mode 100644 src/Entity/User.php create mode 100644 src/Repository/AddressRepository.php create mode 100644 src/Repository/EmailRepository.php create mode 100644 src/Repository/KitchenRepository.php create mode 100644 src/Repository/NewsCategoryRepository.php create mode 100644 src/Repository/NewsCommentRepository.php create mode 100644 src/Repository/NewsRepository.php create mode 100644 src/Repository/NewsTypeRepository.php create mode 100644 src/Repository/PhoneRepository.php create mode 100644 src/Repository/RestaurantRepository.php create mode 100644 src/Repository/RestaurantTypeRepository.php create mode 100644 src/Repository/SettlementRepository.php create mode 100644 src/Repository/TagsRepository.php create mode 100644 src/Repository/UserRepository.php diff --git a/.env b/.env index e6c9e50..0a0d6c5 100644 --- a/.env +++ b/.env @@ -26,7 +26,7 @@ APP_SECRET=ea3ebbf899855d483050e0d1aad6a759 # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4" # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" -DATABASE_URL="postgresql://postgres:12345@127.0.0.1:5432/app?serverVersion=16&charset=utf8" +DATABASE_URL="postgresql://postgres:12345@127.0.0.1:5433/postgres?serverVersion=16&charset=utf8" ###< doctrine/doctrine-bundle ### ###> symfony/messenger ### diff --git a/composer.json b/composer.json index e4fcbc1..b4e8fa8 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "symfony/string": "7.0.*", "symfony/translation": "7.0.*", "symfony/twig-bundle": "7.0.*", + "symfony/uid": "7.0.*", "symfony/ux-turbo": "^2.16", "symfony/validator": "6.4.*", "symfony/web-link": "7.0.*", diff --git a/composer.lock b/composer.lock index 8a0131f..45f3c97 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "82e62585d889ab4827bf4bf460016802", + "content-hash": "b1f7459f48c910e2a39af6ee5a9b80eb", "packages": [ { "name": "composer/semver", @@ -5241,6 +5241,85 @@ ], "time": "2024-01-29T20:11:03+00:00" }, + { + "name": "symfony/polyfill-uuid", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-uuid.git", + "reference": "3abdd21b0ceaa3000ee950097bc3cf9efc137853" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/3abdd21b0ceaa3000ee950097bc3cf9efc137853", + "reference": "3abdd21b0ceaa3000ee950097bc3cf9efc137853", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-uuid": "*" + }, + "suggest": { + "ext-uuid": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Uuid\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Grégoire Pineau", + "email": "lyrixx@lyrixx.info" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for uuid functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "uuid" + ], + "support": { + "source": "https://github.com/symfony/polyfill-uuid/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, { "name": "symfony/process", "version": "v7.0.4", @@ -6729,6 +6808,80 @@ ], "time": "2024-02-15T11:33:06+00:00" }, + { + "name": "symfony/uid", + "version": "v7.0.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/uid.git", + "reference": "87cedaf3fabd7b733859d4d77aa4ca598259054b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/uid/zipball/87cedaf3fabd7b733859d4d77aa4ca598259054b", + "reference": "87cedaf3fabd7b733859d4d77aa4ca598259054b", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-uuid": "^1.15" + }, + "require-dev": { + "symfony/console": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Uid\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Grégoire Pineau", + "email": "lyrixx@lyrixx.info" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to generate and represent UIDs", + "homepage": "https://symfony.com", + "keywords": [ + "UID", + "ulid", + "uuid" + ], + "support": { + "source": "https://github.com/symfony/uid/tree/v7.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T15:02:46+00:00" + }, { "name": "symfony/ux-turbo", "version": "v2.16.0", diff --git a/migrations/Version20240423071100.php b/migrations/Version20240423071100.php new file mode 100644 index 0000000..f16e9f8 --- /dev/null +++ b/migrations/Version20240423071100.php @@ -0,0 +1,103 @@ +addSql('CREATE SEQUENCE address_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE email_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE news_comment_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE news_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE phone_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE restaurant_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE tags_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE address (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_D4E6F81B1E7706E ON address (restaurant_id)'); + $this->addSql('CREATE TABLE email (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_E7927C74B1E7706E ON email (restaurant_id)'); + $this->addSql('CREATE TABLE news (id UUID NOT NULL, type_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 INDEX IDX_1DD39950C54C8C93 ON news (type_id)'); + $this->addSql('COMMENT ON COLUMN news.id IS \'(DC2Type:uuid)\''); + $this->addSql('CREATE TABLE news_comment (id INT NOT NULL, news_id_id UUID NOT NULL, moderator_id_id INT NOT NULL, user_id_id INT NOT NULL, moderated BOOLEAN NOT NULL, user_name VARCHAR(255) NOT NULL, text VARCHAR(255) 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('CREATE UNIQUE INDEX UNIQ_C3904E8A5FB1909 ON news_comment (news_id_id)'); + $this->addSql('CREATE INDEX IDX_C3904E8ACEB712DF ON news_comment (moderator_id_id)'); + $this->addSql('CREATE INDEX IDX_C3904E8A9D86650F ON news_comment (user_id_id)'); + $this->addSql('COMMENT ON COLUMN news_comment.news_id_id IS \'(DC2Type:uuid)\''); + $this->addSql('CREATE TABLE news_type (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE phone (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_444F97DDB1E7706E ON phone (restaurant_id)'); + $this->addSql('CREATE TABLE restaurant (id INT NOT NULL, type_id_id INT NOT NULL, settlement_id_id INT NOT NULL, uuid 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, 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 UNIQUE INDEX UNIQ_EB95123FD17F50A6 ON restaurant (uuid)'); + $this->addSql('CREATE INDEX IDX_EB95123F714819A0 ON restaurant (type_id_id)'); + $this->addSql('CREATE INDEX IDX_EB95123F45EC589B ON restaurant (settlement_id_id)'); + $this->addSql('COMMENT ON COLUMN restaurant.uuid IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN restaurant.coordinates IS \'(DC2Type:array)\''); + $this->addSql('CREATE TABLE tags (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_6FBC9426B1E7706E ON tags (restaurant_id)'); + $this->addSql('ALTER TABLE address ADD CONSTRAINT FK_D4E6F81B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE email ADD CONSTRAINT FK_E7927C74B1E7706E 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_comment ADD CONSTRAINT FK_C3904E8A5FB1909 FOREIGN KEY (news_id_id) REFERENCES news (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8ACEB712DF FOREIGN KEY (moderator_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8A9D86650F FOREIGN KEY (user_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE phone ADD CONSTRAINT FK_444F97DDB1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $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 tags ADD CONSTRAINT FK_6FBC9426B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE kitchen ADD restaurant_id INT NOT NULL'); + $this->addSql('ALTER TABLE kitchen ADD CONSTRAINT FK_EAA3CE34B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_EAA3CE34B1E7706E ON kitchen (restaurant_id)'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649D17F50A6 ON "user" (uuid)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE kitchen DROP CONSTRAINT FK_EAA3CE34B1E7706E'); + $this->addSql('DROP SEQUENCE address_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE email_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE news_comment_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE news_type_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE phone_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE restaurant_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE tags_id_seq CASCADE'); + $this->addSql('ALTER TABLE address DROP CONSTRAINT FK_D4E6F81B1E7706E'); + $this->addSql('ALTER TABLE email DROP CONSTRAINT FK_E7927C74B1E7706E'); + $this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD39950C54C8C93'); + $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8A5FB1909'); + $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8ACEB712DF'); + $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8A9D86650F'); + $this->addSql('ALTER TABLE phone DROP CONSTRAINT FK_444F97DDB1E7706E'); + $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F714819A0'); + $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F45EC589B'); + $this->addSql('ALTER TABLE tags DROP CONSTRAINT FK_6FBC9426B1E7706E'); + $this->addSql('DROP TABLE address'); + $this->addSql('DROP TABLE email'); + $this->addSql('DROP TABLE news'); + $this->addSql('DROP TABLE news_comment'); + $this->addSql('DROP TABLE news_type'); + $this->addSql('DROP TABLE phone'); + $this->addSql('DROP TABLE restaurant'); + $this->addSql('DROP TABLE tags'); + $this->addSql('DROP INDEX UNIQ_8D93D649D17F50A6'); + $this->addSql('DROP INDEX IDX_EAA3CE34B1E7706E'); + $this->addSql('ALTER TABLE kitchen DROP restaurant_id'); + } +} diff --git a/migrations/Version20240423071601.php b/migrations/Version20240423071601.php new file mode 100644 index 0000000..c8b2ca7 --- /dev/null +++ b/migrations/Version20240423071601.php @@ -0,0 +1,40 @@ +addSql('CREATE TABLE news_news_category (news_id UUID NOT NULL, news_category_id UUID NOT NULL, PRIMARY KEY(news_id, news_category_id))'); + $this->addSql('CREATE INDEX IDX_1A91D6D6B5A459A0 ON news_news_category (news_id)'); + $this->addSql('CREATE INDEX IDX_1A91D6D63B732BAD ON news_news_category (news_category_id)'); + $this->addSql('COMMENT ON COLUMN news_news_category.news_id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN news_news_category.news_category_id IS \'(DC2Type:uuid)\''); + $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'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE news_news_category DROP CONSTRAINT FK_1A91D6D6B5A459A0'); + $this->addSql('ALTER TABLE news_news_category DROP CONSTRAINT FK_1A91D6D63B732BAD'); + $this->addSql('DROP TABLE news_news_category'); + } +} diff --git a/src/Entity/Address.php b/src/Entity/Address.php new file mode 100644 index 0000000..6fa2e40 --- /dev/null +++ b/src/Entity/Address.php @@ -0,0 +1,51 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getRestaurant(): ?Restaurant + { + return $this->restaurant; + } + + public function setRestaurant(?Restaurant $restaurant): static + { + $this->restaurant = $restaurant; + + return $this; + } +} diff --git a/src/Entity/Email.php b/src/Entity/Email.php new file mode 100644 index 0000000..ba955db --- /dev/null +++ b/src/Entity/Email.php @@ -0,0 +1,51 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getRestaurant(): ?Restaurant + { + return $this->restaurant; + } + + public function setRestaurant(?Restaurant $restaurant): static + { + $this->restaurant = $restaurant; + + return $this; + } +} diff --git a/src/Entity/Kitchen.php b/src/Entity/Kitchen.php new file mode 100644 index 0000000..2d08475 --- /dev/null +++ b/src/Entity/Kitchen.php @@ -0,0 +1,51 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getRestaurant(): ?Restaurant + { + return $this->restaurant; + } + + public function setRestaurant(?Restaurant $restaurant): static + { + $this->restaurant = $restaurant; + + return $this; + } +} diff --git a/src/Entity/News.php b/src/Entity/News.php new file mode 100644 index 0000000..a4de9af --- /dev/null +++ b/src/Entity/News.php @@ -0,0 +1,224 @@ + + */ + #[ORM\ManyToMany(targetEntity: NewsCategory::class)] + private Collection $newsCategories; + + public function __construct() + { + $this->newsCategories = new ArrayCollection(); + } + + public function getId(): ?Uuid + { + return $this->id; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + public function isActive(): ?bool + { + return $this->active; + } + + public function setActive(bool $active): static + { + $this->active = $active; + + return $this; + } + + public function getCreateAt(): ?\DateTimeInterface + { + return $this->createAt; + } + + public function setCreateAt(\DateTimeInterface $createAt): static + { + $this->createAt = $createAt; + + return $this; + } + + public function getUpdateAt(): ?\DateTimeInterface + { + return $this->updateAt; + } + + public function setUpdateAt(\DateTimeInterface $updateAt): static + { + $this->updateAt = $updateAt; + + return $this; + } + + public function getSort(): ?int + { + return $this->sort; + } + + public function setSort(int $sort): static + { + $this->sort = $sort; + + return $this; + } + + public function getPreviewImage(): ?string + { + return $this->previewImage; + } + + public function setPreviewImage(string $previewImage): static + { + $this->previewImage = $previewImage; + + return $this; + } + + public function getDetailImage(): ?string + { + return $this->detailImage; + } + + public function setDetailImage(string $detailImage): static + { + $this->detailImage = $detailImage; + + return $this; + } + + public function getPreviewText(): ?string + { + return $this->previewText; + } + + public function setPreviewText(string $previewText): static + { + $this->previewText = $previewText; + + return $this; + } + + public function getDetailText(): ?string + { + return $this->detailText; + } + + public function setDetailText(string $detailText): static + { + $this->detailText = $detailText; + + return $this; + } + + public function getType(): ?NewsType + { + return $this->type; + } + + public function setType(?NewsType $type): static + { + $this->type = $type; + + return $this; + } + + public function isMainPageRender(): ?bool + { + return $this->mainPageRender; + } + + public function setMainPageRender(bool $mainPageRender): static + { + $this->mainPageRender = $mainPageRender; + + return $this; + } + + /** + * @return Collection + */ + public function getNewsCategories(): Collection + { + return $this->newsCategories; + } + + public function addNewsCategory(NewsCategory $newsCategory): static + { + if (!$this->newsCategories->contains($newsCategory)) { + $this->newsCategories->add($newsCategory); + } + + return $this; + } + + public function removeNewsCategory(NewsCategory $newsCategory): static + { + $this->newsCategories->removeElement($newsCategory); + + return $this; + } +} diff --git a/src/Entity/NewsCategory.php b/src/Entity/NewsCategory.php new file mode 100644 index 0000000..974a99c --- /dev/null +++ b/src/Entity/NewsCategory.php @@ -0,0 +1,79 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + /** + * @return Collection + */ + public function getNews(): Collection + { + return $this->news; + } + + public function addNews(News $news): static + { + if (!$this->news->contains($news)) { + $this->news->add($news); + $news->addNewsCategory($this); + } + + return $this; + } + + public function removeNews(News $news): static + { + if ($this->news->removeElement($news)) { + $news->removeNewsCategory($this); + } + + return $this; + } +} diff --git a/src/Entity/NewsComment.php b/src/Entity/NewsComment.php new file mode 100644 index 0000000..44f0e48 --- /dev/null +++ b/src/Entity/NewsComment.php @@ -0,0 +1,144 @@ +id; + } + + public function getNewsId(): ?News + { + return $this->newsId; + } + + public function setNewsId(News $newsId): static + { + $this->newsId = $newsId; + + return $this; + } + + public function isModerated(): ?bool + { + return $this->moderated; + } + + public function setModerated(bool $moderated): static + { + $this->moderated = $moderated; + + return $this; + } + + public function getModeratorId(): ?User + { + return $this->moderatorId; + } + + public function setModeratorId(?User $moderatorId): static + { + $this->moderatorId = $moderatorId; + + return $this; + } + + public function getUserName(): ?string + { + return $this->userName; + } + + public function setUserName(string $userName): static + { + $this->userName = $userName; + + return $this; + } + + public function getUserId(): ?User + { + return $this->userId; + } + + public function setUserId(?User $userId): static + { + $this->userId = $userId; + + return $this; + } + + public function getText(): ?string + { + return $this->text; + } + + public function setText(string $text): static + { + $this->text = $text; + + return $this; + } + + public function getCreateAt(): ?\DateTimeInterface + { + return $this->createAt; + } + + public function setCreateAt(\DateTimeInterface $createAt): static + { + $this->createAt = $createAt; + + return $this; + } + + public function getUpdateAt(): ?\DateTimeImmutable + { + return $this->updateAt; + } + + public function setUpdateAt(\DateTimeImmutable $updateAt): static + { + $this->updateAt = $updateAt; + + return $this; + } +} diff --git a/src/Entity/NewsType.php b/src/Entity/NewsType.php new file mode 100644 index 0000000..409ac09 --- /dev/null +++ b/src/Entity/NewsType.php @@ -0,0 +1,78 @@ + + */ + #[ORM\OneToMany(targetEntity: News::class, mappedBy: 'type')] + private Collection $news; + + public function __construct() + { + $this->news = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + /** + * @return Collection + */ + public function getNews(): Collection + { + return $this->news; + } + + public function addNews(News $news): static + { + if (!$this->news->contains($news)) { + $this->news->add($news); + $news->setType($this); + } + + return $this; + } + + public function removeNews(News $news): static + { + if ($this->news->removeElement($news)) { + // set the owning side to null (unless already changed) + if ($news->getType() === $this) { + $news->setType(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Phone.php b/src/Entity/Phone.php new file mode 100644 index 0000000..00c028f --- /dev/null +++ b/src/Entity/Phone.php @@ -0,0 +1,51 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getRestaurant(): ?Restaurant + { + return $this->restaurant; + } + + public function setRestaurant(?Restaurant $restaurant): static + { + $this->restaurant = $restaurant; + + return $this; + } +} diff --git a/src/Entity/Restaurant.php b/src/Entity/Restaurant.php new file mode 100644 index 0000000..02fd3b1 --- /dev/null +++ b/src/Entity/Restaurant.php @@ -0,0 +1,470 @@ + + */ + #[ORM\OneToMany(targetEntity: Kitchen::class, mappedBy: 'restaurant')] + private Collection $kitchen; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Phone::class, mappedBy: 'restaurant')] + private Collection $phone; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Email::class, mappedBy: 'restaurant')] + private Collection $email; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Address::class, mappedBy: 'restaurant')] + private Collection $address; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Tags::class, mappedBy: 'restaurant')] + private Collection $tags; + + #[ORM\Column(length: 255)] + private ?string $site = null; + + #[ORM\Column(length: 255)] + private ?string $previewImage = null; + + #[ORM\Column(length: 255)] + private ?string $detailImage = null; + + #[ORM\Column(type: Types::TEXT)] + private ?string $howToFind = null; + + public function __construct() + { + $this->kitchen = new ArrayCollection(); + $this->phone = new ArrayCollection(); + $this->email = new ArrayCollection(); + $this->address = new ArrayCollection(); + $this->tags = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getUuid(): ?Uuid + { + return $this->uuid; + } + + public function setUuid(Uuid $uuid): static + { + $this->uuid = $uuid; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + public function isActive(): ?bool + { + return $this->active; + } + + public function setActive(bool $active): static + { + $this->active = $active; + + return $this; + } + + public function getSort(): ?int + { + return $this->sort; + } + + public function setSort(int $sort): static + { + $this->sort = $sort; + + return $this; + } + + public function getCreateAt(): ?\DateTimeInterface + { + return $this->createAt; + } + + public function setCreateAt(\DateTimeInterface $createAt): static + { + $this->createAt = $createAt; + + return $this; + } + + public function getUpdateAt(): ?\DateTimeInterface + { + return $this->updateAt; + } + + public function setUpdateAt(\DateTimeInterface $updateAt): static + { + $this->updateAt = $updateAt; + + return $this; + } + + public function getCoordinates(): array + { + return $this->coordinates; + } + + public function setCoordinates(array $coordinates): static + { + $this->coordinates = $coordinates; + + return $this; + } + + public function getTypeId(): ?RestaurantType + { + return $this->typeId; + } + + public function setTypeId(?RestaurantType $typeId): static + { + $this->typeId = $typeId; + + return $this; + } + + public function getSettlementId(): ?Settlement + { + return $this->settlementId; + } + + public function setSettlementId(?Settlement $settlementId): static + { + $this->settlementId = $settlementId; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(string $description): static + { + $this->description = $description; + + return $this; + } + + public function getCheckPrice(): ?string + { + return $this->checkPrice; + } + + public function setCheckPrice(string $checkPrice): static + { + $this->checkPrice = $checkPrice; + + return $this; + } + + public function getCheckInfo(): ?string + { + return $this->checkInfo; + } + + public function setCheckInfo(string $checkInfo): static + { + $this->checkInfo = $checkInfo; + + return $this; + } + + /** + * @return Collection + */ + public function getKitchen(): Collection + { + return $this->kitchen; + } + + public function addKitchen(Kitchen $kitchen): static + { + if (!$this->kitchen->contains($kitchen)) { + $this->kitchen->add($kitchen); + $kitchen->setRestaurant($this); + } + + return $this; + } + + public function removeKitchen(Kitchen $kitchen): static + { + if ($this->kitchen->removeElement($kitchen)) { + // set the owning side to null (unless already changed) + if ($kitchen->getRestaurant() === $this) { + $kitchen->setRestaurant(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getPhone(): Collection + { + return $this->phone; + } + + public function addPhone(Phone $phone): static + { + if (!$this->phone->contains($phone)) { + $this->phone->add($phone); + $phone->setRestaurant($this); + } + + return $this; + } + + public function removePhone(Phone $phone): static + { + if ($this->phone->removeElement($phone)) { + // set the owning side to null (unless already changed) + if ($phone->getRestaurant() === $this) { + $phone->setRestaurant(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getEmail(): Collection + { + return $this->email; + } + + public function addEmail(Email $email): static + { + if (!$this->email->contains($email)) { + $this->email->add($email); + $email->setRestaurant($this); + } + + return $this; + } + + public function removeEmail(Email $email): static + { + if ($this->email->removeElement($email)) { + // set the owning side to null (unless already changed) + if ($email->getRestaurant() === $this) { + $email->setRestaurant(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getAddress(): Collection + { + return $this->address; + } + + public function addAddress(Address $address): static + { + if (!$this->address->contains($address)) { + $this->address->add($address); + $address->setRestaurant($this); + } + + return $this; + } + + public function removeAddress(Address $address): static + { + if ($this->address->removeElement($address)) { + // set the owning side to null (unless already changed) + if ($address->getRestaurant() === $this) { + $address->setRestaurant(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getTags(): Collection + { + return $this->tags; + } + + public function addTag(Tags $tag): static + { + if (!$this->tags->contains($tag)) { + $this->tags->add($tag); + $tag->setRestaurant($this); + } + + return $this; + } + + public function removeTag(Tags $tag): static + { + if ($this->tags->removeElement($tag)) { + // set the owning side to null (unless already changed) + if ($tag->getRestaurant() === $this) { + $tag->setRestaurant(null); + } + } + + return $this; + } + + public function getSite(): ?string + { + return $this->site; + } + + public function setSite(string $site): static + { + $this->site = $site; + + return $this; + } + + public function getPreviewImage(): ?string + { + return $this->previewImage; + } + + public function setPreviewImage(string $previewImage): static + { + $this->previewImage = $previewImage; + + return $this; + } + + public function getDetailImage(): ?string + { + return $this->detailImage; + } + + public function setDetailImage(string $detailImage): static + { + $this->detailImage = $detailImage; + + return $this; + } + + public function getHowToFind(): ?string + { + return $this->howToFind; + } + + public function setHowToFind(string $howToFind): static + { + $this->howToFind = $howToFind; + + return $this; + } +} diff --git a/src/Entity/RestaurantType.php b/src/Entity/RestaurantType.php new file mode 100644 index 0000000..2698a85 --- /dev/null +++ b/src/Entity/RestaurantType.php @@ -0,0 +1,93 @@ + + */ + #[ORM\OneToMany(targetEntity: Restaurant::class, mappedBy: 'typeId')] + private Collection $restaurants; + + public function __construct() + { + $this->restaurants = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + /** + * @return Collection + */ + public function getRestaurants(): Collection + { + return $this->restaurants; + } + + public function addRestaurant(Restaurant $restaurant): static + { + if (!$this->restaurants->contains($restaurant)) { + $this->restaurants->add($restaurant); + $restaurant->setTypeId($this); + } + + return $this; + } + + public function removeRestaurant(Restaurant $restaurant): static + { + if ($this->restaurants->removeElement($restaurant)) { + // set the owning side to null (unless already changed) + if ($restaurant->getTypeId() === $this) { + $restaurant->setTypeId(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Settlement.php b/src/Entity/Settlement.php new file mode 100644 index 0000000..9f983df --- /dev/null +++ b/src/Entity/Settlement.php @@ -0,0 +1,155 @@ + + */ + #[ORM\OneToMany(targetEntity: Restaurant::class, mappedBy: 'settlementId')] + private Collection $restaurants; + + public function __construct() + { + $this->restaurants = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getUuid(): ?Uuid + { + return $this->uuid; + } + + public function setUuid(Uuid $uuid): static + { + $this->uuid = $uuid; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + public function getCoordinates(): array + { + return $this->coordinates; + } + + public function setCoordinates(array $coordinates): static + { + $this->coordinates = $coordinates; + + return $this; + } + + public function getCreateAt(): ?\DateTimeInterface + { + return $this->createAt; + } + + public function setCreateAt(\DateTimeInterface $createAt): static + { + $this->createAt = $createAt; + + return $this; + } + + public function getUpdateAt(): ?\DateTimeInterface + { + return $this->updateAt; + } + + public function setUpdateAt(\DateTimeInterface $updateAt): static + { + $this->updateAt = $updateAt; + + return $this; + } + + /** + * @return Collection + */ + public function getRestaurants(): Collection + { + return $this->restaurants; + } + + public function addRestaurant(Restaurant $restaurant): static + { + if (!$this->restaurants->contains($restaurant)) { + $this->restaurants->add($restaurant); + $restaurant->setSettlementId($this); + } + + return $this; + } + + public function removeRestaurant(Restaurant $restaurant): static + { + if ($this->restaurants->removeElement($restaurant)) { + // set the owning side to null (unless already changed) + if ($restaurant->getSettlementId() === $this) { + $restaurant->setSettlementId(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Tags.php b/src/Entity/Tags.php new file mode 100644 index 0000000..34514ad --- /dev/null +++ b/src/Entity/Tags.php @@ -0,0 +1,51 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getRestaurant(): ?Restaurant + { + return $this->restaurant; + } + + public function setRestaurant(?Restaurant $restaurant): static + { + $this->restaurant = $restaurant; + + return $this; + } +} diff --git a/src/Entity/User.php b/src/Entity/User.php new file mode 100644 index 0000000..7f1d85e --- /dev/null +++ b/src/Entity/User.php @@ -0,0 +1,95 @@ + + */ + #[ORM\OneToMany(targetEntity: NewsComment::class, mappedBy: 'userId')] + private Collection $newsComments; + + public function __construct() + { + $this->newsComments = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getUuid(): ?Uuid + { + return $this->uuid; + } + + public function setUuid(Uuid $uuid): static + { + $this->uuid = $uuid; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + /** + * @return Collection + */ + public function getNewsComments(): Collection + { + return $this->newsComments; + } + + public function addNewsComment(NewsComment $newsComment): static + { + if (!$this->newsComments->contains($newsComment)) { + $this->newsComments->add($newsComment); + $newsComment->setUserId($this); + } + + return $this; + } + + public function removeNewsComment(NewsComment $newsComment): static + { + if ($this->newsComments->removeElement($newsComment)) { + // set the owning side to null (unless already changed) + if ($newsComment->getUserId() === $this) { + $newsComment->setUserId(null); + } + } + + return $this; + } +} diff --git a/src/Repository/AddressRepository.php b/src/Repository/AddressRepository.php new file mode 100644 index 0000000..e87117f --- /dev/null +++ b/src/Repository/AddressRepository.php @@ -0,0 +1,48 @@ + + * + * @method Address|null find($id, $lockMode = null, $lockVersion = null) + * @method Address|null findOneBy(array $criteria, array $orderBy = null) + * @method Address[] findAll() + * @method Address[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class AddressRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Address::class); + } + +// /** +// * @return Address[] Returns an array of Address objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('a') +// ->andWhere('a.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('a.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Address +// { +// return $this->createQueryBuilder('a') +// ->andWhere('a.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/EmailRepository.php b/src/Repository/EmailRepository.php new file mode 100644 index 0000000..f22b0ee --- /dev/null +++ b/src/Repository/EmailRepository.php @@ -0,0 +1,48 @@ + + * + * @method Email|null find($id, $lockMode = null, $lockVersion = null) + * @method Email|null findOneBy(array $criteria, array $orderBy = null) + * @method Email[] findAll() + * @method Email[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class EmailRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Email::class); + } + +// /** +// * @return Email[] Returns an array of Email objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('e') +// ->andWhere('e.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('e.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Email +// { +// return $this->createQueryBuilder('e') +// ->andWhere('e.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/KitchenRepository.php b/src/Repository/KitchenRepository.php new file mode 100644 index 0000000..745766d --- /dev/null +++ b/src/Repository/KitchenRepository.php @@ -0,0 +1,48 @@ + + * + * @method Kitchen|null find($id, $lockMode = null, $lockVersion = null) + * @method Kitchen|null findOneBy(array $criteria, array $orderBy = null) + * @method Kitchen[] findAll() + * @method Kitchen[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class KitchenRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Kitchen::class); + } + +// /** +// * @return Kitchen[] Returns an array of Kitchen objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('k') +// ->andWhere('k.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('k.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Kitchen +// { +// return $this->createQueryBuilder('k') +// ->andWhere('k.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/NewsCategoryRepository.php b/src/Repository/NewsCategoryRepository.php new file mode 100644 index 0000000..3a5eeeb --- /dev/null +++ b/src/Repository/NewsCategoryRepository.php @@ -0,0 +1,48 @@ + + * + * @method NewsCategory|null find($id, $lockMode = null, $lockVersion = null) + * @method NewsCategory|null findOneBy(array $criteria, array $orderBy = null) + * @method NewsCategory[] findAll() + * @method NewsCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class NewsCategoryRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, NewsCategory::class); + } + +// /** +// * @return NewsCategory[] Returns an array of NewsCategory objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('n') +// ->andWhere('n.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('n.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?NewsCategory +// { +// return $this->createQueryBuilder('n') +// ->andWhere('n.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/NewsCommentRepository.php b/src/Repository/NewsCommentRepository.php new file mode 100644 index 0000000..1784010 --- /dev/null +++ b/src/Repository/NewsCommentRepository.php @@ -0,0 +1,48 @@ + + * + * @method NewsComment|null find($id, $lockMode = null, $lockVersion = null) + * @method NewsComment|null findOneBy(array $criteria, array $orderBy = null) + * @method NewsComment[] findAll() + * @method NewsComment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class NewsCommentRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, NewsComment::class); + } + +// /** +// * @return NewsComment[] Returns an array of NewsComment objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('n') +// ->andWhere('n.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('n.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?NewsComment +// { +// return $this->createQueryBuilder('n') +// ->andWhere('n.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/NewsRepository.php b/src/Repository/NewsRepository.php new file mode 100644 index 0000000..3b5d864 --- /dev/null +++ b/src/Repository/NewsRepository.php @@ -0,0 +1,48 @@ + + * + * @method News|null find($id, $lockMode = null, $lockVersion = null) + * @method News|null findOneBy(array $criteria, array $orderBy = null) + * @method News[] findAll() + * @method News[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class NewsRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, News::class); + } + +// /** +// * @return News[] Returns an array of News objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('n') +// ->andWhere('n.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('n.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?News +// { +// return $this->createQueryBuilder('n') +// ->andWhere('n.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/NewsTypeRepository.php b/src/Repository/NewsTypeRepository.php new file mode 100644 index 0000000..385998b --- /dev/null +++ b/src/Repository/NewsTypeRepository.php @@ -0,0 +1,48 @@ + + * + * @method NewsType|null find($id, $lockMode = null, $lockVersion = null) + * @method NewsType|null findOneBy(array $criteria, array $orderBy = null) + * @method NewsType[] findAll() + * @method NewsType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class NewsTypeRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, NewsType::class); + } + +// /** +// * @return NewsType[] Returns an array of NewsType objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('n') +// ->andWhere('n.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('n.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?NewsType +// { +// return $this->createQueryBuilder('n') +// ->andWhere('n.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/PhoneRepository.php b/src/Repository/PhoneRepository.php new file mode 100644 index 0000000..de389d6 --- /dev/null +++ b/src/Repository/PhoneRepository.php @@ -0,0 +1,48 @@ + + * + * @method Phone|null find($id, $lockMode = null, $lockVersion = null) + * @method Phone|null findOneBy(array $criteria, array $orderBy = null) + * @method Phone[] findAll() + * @method Phone[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class PhoneRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Phone::class); + } + +// /** +// * @return Phone[] Returns an array of Phone objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('p') +// ->andWhere('p.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('p.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Phone +// { +// return $this->createQueryBuilder('p') +// ->andWhere('p.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/RestaurantRepository.php b/src/Repository/RestaurantRepository.php new file mode 100644 index 0000000..8b5b18d --- /dev/null +++ b/src/Repository/RestaurantRepository.php @@ -0,0 +1,48 @@ + + * + * @method Restaurant|null find($id, $lockMode = null, $lockVersion = null) + * @method Restaurant|null findOneBy(array $criteria, array $orderBy = null) + * @method Restaurant[] findAll() + * @method Restaurant[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class RestaurantRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Restaurant::class); + } + +// /** +// * @return Restaurant[] Returns an array of Restaurant objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('r') +// ->andWhere('r.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('r.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Restaurant +// { +// return $this->createQueryBuilder('r') +// ->andWhere('r.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/RestaurantTypeRepository.php b/src/Repository/RestaurantTypeRepository.php new file mode 100644 index 0000000..30e6a42 --- /dev/null +++ b/src/Repository/RestaurantTypeRepository.php @@ -0,0 +1,48 @@ + + * + * @method RestaurantType|null find($id, $lockMode = null, $lockVersion = null) + * @method RestaurantType|null findOneBy(array $criteria, array $orderBy = null) + * @method RestaurantType[] findAll() + * @method RestaurantType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class RestaurantTypeRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, RestaurantType::class); + } + +// /** +// * @return RestaurantType[] Returns an array of RestaurantType objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('r') +// ->andWhere('r.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('r.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?RestaurantType +// { +// return $this->createQueryBuilder('r') +// ->andWhere('r.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/SettlementRepository.php b/src/Repository/SettlementRepository.php new file mode 100644 index 0000000..1b5e100 --- /dev/null +++ b/src/Repository/SettlementRepository.php @@ -0,0 +1,48 @@ + + * + * @method Settlement|null find($id, $lockMode = null, $lockVersion = null) + * @method Settlement|null findOneBy(array $criteria, array $orderBy = null) + * @method Settlement[] findAll() + * @method Settlement[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class SettlementRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Settlement::class); + } + +// /** +// * @return Settlement[] Returns an array of Settlement objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('s.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Settlement +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/TagsRepository.php b/src/Repository/TagsRepository.php new file mode 100644 index 0000000..4f01463 --- /dev/null +++ b/src/Repository/TagsRepository.php @@ -0,0 +1,48 @@ + + * + * @method Tags|null find($id, $lockMode = null, $lockVersion = null) + * @method Tags|null findOneBy(array $criteria, array $orderBy = null) + * @method Tags[] findAll() + * @method Tags[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class TagsRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Tags::class); + } + +// /** +// * @return Tags[] Returns an array of Tags objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('t') +// ->andWhere('t.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('t.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Tags +// { +// return $this->createQueryBuilder('t') +// ->andWhere('t.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php new file mode 100644 index 0000000..3767526 --- /dev/null +++ b/src/Repository/UserRepository.php @@ -0,0 +1,48 @@ + + * + * @method User|null find($id, $lockMode = null, $lockVersion = null) + * @method User|null findOneBy(array $criteria, array $orderBy = null) + * @method User[] findAll() + * @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class UserRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, User::class); + } + +// /** +// * @return User[] Returns an array of User objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('u') +// ->andWhere('u.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('u.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?User +// { +// return $this->createQueryBuilder('u') +// ->andWhere('u.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/symfony.lock b/symfony.lock index aaf3e50..f28d08f 100644 --- a/symfony.lock +++ b/symfony.lock @@ -248,6 +248,15 @@ "./templates/base.html.twig" ] }, + "symfony/uid": { + "version": "7.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "7.0", + "ref": "0df5844274d871b37fc3816c57a768ffc60a43a5" + } + }, "symfony/ux-turbo": { "version": "v2.16.0" }, -- GitLab From fe576cc74036faf5982184fd935986305ae7ce5b Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Fri, 26 Apr 2024 12:01:26 +0500 Subject: [PATCH 02/11] =?UTF-8?q?STA-965=20|=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20.env=20=D0=B2=20.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 ++ .gitignore | 4 +++- docker-compose.yaml | 6 ++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.env b/.env index 0a0d6c5..988a069 100644 --- a/.env +++ b/.env @@ -42,3 +42,5 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 DATABASE_PORT="5432" NGINX_PORT="80" APP_BASE_DIR="./" +POSTGRES_USER="postgres" +POSTGRES_PASSWORD="12345" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 930e1e2..f8810d3 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ /public/assets/ /assets/vendor/ ###< symfony/asset-mapper ### -/.idea \ No newline at end of file +/.idea +.env +.env.test \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 9a33442..b41d486 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,8 +5,8 @@ services: container_name: postgres image: postgres:16.2-alpine environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: 12345 + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_HOST_AUTH_METHOD: trust ports: - "${DATABASE_PORT}:${DATABASE_PORT}" @@ -33,8 +33,6 @@ services: APP_BASE_DIR: ${APP_BASE_DIR-.} volumes: - ".:/app" - ports: - - "9000:9000" restart: unless-stopped networks: - internal -- GitLab From 07a80ff9ceaa6cde2e93c70082fe695d5147d010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B4=D0=BB=D0=B0=D0=BD=20=D0=A8=D0=B0=D0=BC=D0=B0?= =?UTF-8?q?=D0=B2=D0=BE=D0=B2?= Date: Fri, 26 Apr 2024 07:08:56 +0000 Subject: [PATCH 03/11] Delete .env --- .env | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 988a069..0000000 --- a/.env +++ /dev/null @@ -1,46 +0,0 @@ -# In all environments, the following files are loaded if they exist, -# the latter taking precedence over the former: -# -# * .env contains default values for the environment variables needed by the app -# * .env.local uncommitted file with local overrides -# * .env.$APP_ENV committed environment-specific defaults -# * .env.$APP_ENV.local uncommitted environment-specific overrides -# -# Real environment variables win over .env files. -# -# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. -# https://symfony.com/doc/current/configuration/secrets.html -# -# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). -# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration - -###> symfony/framework-bundle ### -APP_ENV=dev -APP_SECRET=ea3ebbf899855d483050e0d1aad6a759 -###< symfony/framework-bundle ### - -###> doctrine/doctrine-bundle ### -# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url -# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml -# -# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" -# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4" -# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" -DATABASE_URL="postgresql://postgres:12345@127.0.0.1:5433/postgres?serverVersion=16&charset=utf8" -###< doctrine/doctrine-bundle ### - -###> symfony/messenger ### -# Choose one of the transports below -# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages -# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages -MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 -###< symfony/messenger ### - -###> symfony/mailer ### -# MAILER_DSN=null://null -###< symfony/mailer ### -DATABASE_PORT="5432" -NGINX_PORT="80" -APP_BASE_DIR="./" -POSTGRES_USER="postgres" -POSTGRES_PASSWORD="12345" \ No newline at end of file -- GitLab From ed43f8232fe152eb74ff985a1a10f8cf46317a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B4=D0=BB=D0=B0=D0=BD=20=D0=A8=D0=B0=D0=BC=D0=B0?= =?UTF-8?q?=D0=B2=D0=BE=D0=B2?= Date: Fri, 26 Apr 2024 07:09:12 +0000 Subject: [PATCH 04/11] Delete .env.test --- .env.test | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .env.test diff --git a/.env.test b/.env.test deleted file mode 100644 index 9e7162f..0000000 --- a/.env.test +++ /dev/null @@ -1,6 +0,0 @@ -# define your env variables for the test env here -KERNEL_CLASS='App\Kernel' -APP_SECRET='$ecretf0rt3st' -SYMFONY_DEPRECATIONS_HELPER=999999 -PANTHER_APP_ENV=panther -PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots -- GitLab From 0d010a158f1cf1703b4e227419c71773bb8b830d Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Thu, 2 May 2024 12:53:14 +0500 Subject: [PATCH 05/11] =?UTF-8?q?STA-965=20|=20=D0=9E=D0=B1=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D1=81=D1=85=D0=B5=D0=BC=D1=83=20=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrations/Version20240423071100.php | 103 -------------------------- migrations/Version20240423071601.php | 40 ---------- src/Entity/Address.php | 51 ------------- src/Entity/Email.php | 51 ------------- src/Entity/File.php | 102 +++++++++++++++++++++++++ src/Entity/{Phone.php => Gallery.php} | 31 ++++---- src/Entity/Kitchen.php | 8 +- src/Entity/News.php | 20 ++++- src/Entity/NewsCategory.php | 27 ------- src/Entity/NewsComment.php | 12 +-- src/Entity/NewsType.php | 8 +- src/Entity/Restaurant.php | 94 ++++++++++++++--------- src/Entity/RestaurantType.php | 8 +- src/Entity/Seo.php | 65 ++++++++++++++++ src/Entity/Settlement.php | 24 +----- src/Entity/Tags.php | 24 +++++- src/Entity/User.php | 19 +---- src/Repository/AddressRepository.php | 48 ------------ src/Repository/EmailRepository.php | 48 ------------ src/Repository/FileRepository.php | 48 ++++++++++++ src/Repository/GalleryRepository.php | 48 ++++++++++++ src/Repository/PhoneRepository.php | 48 ------------ src/Repository/SeoRepository.php | 48 ++++++++++++ tests/RestaurantControllerTest.php | 63 ++++++++++++++++ 24 files changed, 514 insertions(+), 524 deletions(-) delete mode 100644 migrations/Version20240423071100.php delete mode 100644 migrations/Version20240423071601.php delete mode 100644 src/Entity/Address.php delete mode 100644 src/Entity/Email.php create mode 100644 src/Entity/File.php rename src/Entity/{Phone.php => Gallery.php} (58%) create mode 100644 src/Entity/Seo.php delete mode 100644 src/Repository/AddressRepository.php delete mode 100644 src/Repository/EmailRepository.php create mode 100644 src/Repository/FileRepository.php create mode 100644 src/Repository/GalleryRepository.php delete mode 100644 src/Repository/PhoneRepository.php create mode 100644 src/Repository/SeoRepository.php create mode 100644 tests/RestaurantControllerTest.php diff --git a/migrations/Version20240423071100.php b/migrations/Version20240423071100.php deleted file mode 100644 index f16e9f8..0000000 --- a/migrations/Version20240423071100.php +++ /dev/null @@ -1,103 +0,0 @@ -addSql('CREATE SEQUENCE address_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE SEQUENCE email_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE SEQUENCE news_comment_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE SEQUENCE news_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE SEQUENCE phone_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE SEQUENCE restaurant_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE SEQUENCE tags_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE TABLE address (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX IDX_D4E6F81B1E7706E ON address (restaurant_id)'); - $this->addSql('CREATE TABLE email (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX IDX_E7927C74B1E7706E ON email (restaurant_id)'); - $this->addSql('CREATE TABLE news (id UUID NOT NULL, type_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 INDEX IDX_1DD39950C54C8C93 ON news (type_id)'); - $this->addSql('COMMENT ON COLUMN news.id IS \'(DC2Type:uuid)\''); - $this->addSql('CREATE TABLE news_comment (id INT NOT NULL, news_id_id UUID NOT NULL, moderator_id_id INT NOT NULL, user_id_id INT NOT NULL, moderated BOOLEAN NOT NULL, user_name VARCHAR(255) NOT NULL, text VARCHAR(255) 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('CREATE UNIQUE INDEX UNIQ_C3904E8A5FB1909 ON news_comment (news_id_id)'); - $this->addSql('CREATE INDEX IDX_C3904E8ACEB712DF ON news_comment (moderator_id_id)'); - $this->addSql('CREATE INDEX IDX_C3904E8A9D86650F ON news_comment (user_id_id)'); - $this->addSql('COMMENT ON COLUMN news_comment.news_id_id IS \'(DC2Type:uuid)\''); - $this->addSql('CREATE TABLE news_type (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE TABLE phone (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX IDX_444F97DDB1E7706E ON phone (restaurant_id)'); - $this->addSql('CREATE TABLE restaurant (id INT NOT NULL, type_id_id INT NOT NULL, settlement_id_id INT NOT NULL, uuid 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, 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 UNIQUE INDEX UNIQ_EB95123FD17F50A6 ON restaurant (uuid)'); - $this->addSql('CREATE INDEX IDX_EB95123F714819A0 ON restaurant (type_id_id)'); - $this->addSql('CREATE INDEX IDX_EB95123F45EC589B ON restaurant (settlement_id_id)'); - $this->addSql('COMMENT ON COLUMN restaurant.uuid IS \'(DC2Type:uuid)\''); - $this->addSql('COMMENT ON COLUMN restaurant.coordinates IS \'(DC2Type:array)\''); - $this->addSql('CREATE TABLE tags (id INT NOT NULL, restaurant_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX IDX_6FBC9426B1E7706E ON tags (restaurant_id)'); - $this->addSql('ALTER TABLE address ADD CONSTRAINT FK_D4E6F81B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE email ADD CONSTRAINT FK_E7927C74B1E7706E 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_comment ADD CONSTRAINT FK_C3904E8A5FB1909 FOREIGN KEY (news_id_id) REFERENCES news (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8ACEB712DF FOREIGN KEY (moderator_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8A9D86650F FOREIGN KEY (user_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE phone ADD CONSTRAINT FK_444F97DDB1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $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 tags ADD CONSTRAINT FK_6FBC9426B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE kitchen ADD restaurant_id INT NOT NULL'); - $this->addSql('ALTER TABLE kitchen ADD CONSTRAINT FK_EAA3CE34B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX IDX_EAA3CE34B1E7706E ON kitchen (restaurant_id)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649D17F50A6 ON "user" (uuid)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE kitchen DROP CONSTRAINT FK_EAA3CE34B1E7706E'); - $this->addSql('DROP SEQUENCE address_id_seq CASCADE'); - $this->addSql('DROP SEQUENCE email_id_seq CASCADE'); - $this->addSql('DROP SEQUENCE news_comment_id_seq CASCADE'); - $this->addSql('DROP SEQUENCE news_type_id_seq CASCADE'); - $this->addSql('DROP SEQUENCE phone_id_seq CASCADE'); - $this->addSql('DROP SEQUENCE restaurant_id_seq CASCADE'); - $this->addSql('DROP SEQUENCE tags_id_seq CASCADE'); - $this->addSql('ALTER TABLE address DROP CONSTRAINT FK_D4E6F81B1E7706E'); - $this->addSql('ALTER TABLE email DROP CONSTRAINT FK_E7927C74B1E7706E'); - $this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD39950C54C8C93'); - $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8A5FB1909'); - $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8ACEB712DF'); - $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8A9D86650F'); - $this->addSql('ALTER TABLE phone DROP CONSTRAINT FK_444F97DDB1E7706E'); - $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F714819A0'); - $this->addSql('ALTER TABLE restaurant DROP CONSTRAINT FK_EB95123F45EC589B'); - $this->addSql('ALTER TABLE tags DROP CONSTRAINT FK_6FBC9426B1E7706E'); - $this->addSql('DROP TABLE address'); - $this->addSql('DROP TABLE email'); - $this->addSql('DROP TABLE news'); - $this->addSql('DROP TABLE news_comment'); - $this->addSql('DROP TABLE news_type'); - $this->addSql('DROP TABLE phone'); - $this->addSql('DROP TABLE restaurant'); - $this->addSql('DROP TABLE tags'); - $this->addSql('DROP INDEX UNIQ_8D93D649D17F50A6'); - $this->addSql('DROP INDEX IDX_EAA3CE34B1E7706E'); - $this->addSql('ALTER TABLE kitchen DROP restaurant_id'); - } -} diff --git a/migrations/Version20240423071601.php b/migrations/Version20240423071601.php deleted file mode 100644 index c8b2ca7..0000000 --- a/migrations/Version20240423071601.php +++ /dev/null @@ -1,40 +0,0 @@ -addSql('CREATE TABLE news_news_category (news_id UUID NOT NULL, news_category_id UUID NOT NULL, PRIMARY KEY(news_id, news_category_id))'); - $this->addSql('CREATE INDEX IDX_1A91D6D6B5A459A0 ON news_news_category (news_id)'); - $this->addSql('CREATE INDEX IDX_1A91D6D63B732BAD ON news_news_category (news_category_id)'); - $this->addSql('COMMENT ON COLUMN news_news_category.news_id IS \'(DC2Type:uuid)\''); - $this->addSql('COMMENT ON COLUMN news_news_category.news_category_id IS \'(DC2Type:uuid)\''); - $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'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE news_news_category DROP CONSTRAINT FK_1A91D6D6B5A459A0'); - $this->addSql('ALTER TABLE news_news_category DROP CONSTRAINT FK_1A91D6D63B732BAD'); - $this->addSql('DROP TABLE news_news_category'); - } -} diff --git a/src/Entity/Address.php b/src/Entity/Address.php deleted file mode 100644 index 6fa2e40..0000000 --- a/src/Entity/Address.php +++ /dev/null @@ -1,51 +0,0 @@ -id; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(string $name): static - { - $this->name = $name; - - return $this; - } - - public function getRestaurant(): ?Restaurant - { - return $this->restaurant; - } - - public function setRestaurant(?Restaurant $restaurant): static - { - $this->restaurant = $restaurant; - - return $this; - } -} diff --git a/src/Entity/Email.php b/src/Entity/Email.php deleted file mode 100644 index ba955db..0000000 --- a/src/Entity/Email.php +++ /dev/null @@ -1,51 +0,0 @@ -id; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(string $name): static - { - $this->name = $name; - - return $this; - } - - public function getRestaurant(): ?Restaurant - { - return $this->restaurant; - } - - public function setRestaurant(?Restaurant $restaurant): static - { - $this->restaurant = $restaurant; - - return $this; - } -} diff --git a/src/Entity/File.php b/src/Entity/File.php new file mode 100644 index 0000000..39432fc --- /dev/null +++ b/src/Entity/File.php @@ -0,0 +1,102 @@ +id; + } + + public function setId(Uuid $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(string $description): static + { + $this->description = $description; + + return $this; + } + + public function getSize(): ?int + { + return $this->size; + } + + public function setSize(int $size): static + { + $this->size = $size; + + return $this; + } + + public function getType(): ?string + { + return $this->type; + } + + public function setType(string $type): static + { + $this->type = $type; + + return $this; + } + + public function getUrl(): ?string + { + return $this->url; + } + + public function setUrl(string $url): static + { + $this->url = $url; + + return $this; + } +} diff --git a/src/Entity/Phone.php b/src/Entity/Gallery.php similarity index 58% rename from src/Entity/Phone.php rename to src/Entity/Gallery.php index 00c028f..1edce96 100644 --- a/src/Entity/Phone.php +++ b/src/Entity/Gallery.php @@ -2,49 +2,50 @@ namespace App\Entity; -use App\Repository\PhoneRepository; +use App\Repository\GalleryRepository; use Doctrine\ORM\Mapping as ORM; -#[ORM\Entity(repositoryClass: PhoneRepository::class)] -class Phone +#[ORM\Entity(repositoryClass: GalleryRepository::class)] +class Gallery { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; - #[ORM\Column(length: 255)] - private ?string $name = null; - - #[ORM\ManyToOne(inversedBy: 'phone')] + #[ORM\ManyToOne(inversedBy: 'galleries')] #[ORM\JoinColumn(nullable: false)] private ?Restaurant $restaurant = null; + #[ORM\OneToOne(cascade: ['persist', 'remove'])] + #[ORM\JoinColumn(nullable: false)] + private ?File $file = null; + public function getId(): ?int { return $this->id; } - public function getName(): ?string + public function getRestaurant(): ?Restaurant { - return $this->name; + return $this->restaurant; } - public function setName(string $name): static + public function setRestaurant(?Restaurant $restaurant): static { - $this->name = $name; + $this->restaurant = $restaurant; return $this; } - public function getRestaurant(): ?Restaurant + public function getFile(): ?File { - return $this->restaurant; + return $this->file; } - public function setRestaurant(?Restaurant $restaurant): static + public function setFile(File $file): static { - $this->restaurant = $restaurant; + $this->file = $file; return $this; } diff --git a/src/Entity/Kitchen.php b/src/Entity/Kitchen.php index 2d08475..0315324 100644 --- a/src/Entity/Kitchen.php +++ b/src/Entity/Kitchen.php @@ -4,14 +4,14 @@ namespace App\Entity; use App\Repository\KitchenRepository; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: KitchenRepository::class)] class Kitchen { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; + #[ORM\Column(type: 'uuid', unique: true)] + private ?Uuid $id = null; #[ORM\Column(length: 255)] private ?string $name = null; @@ -20,7 +20,7 @@ class Kitchen #[ORM\JoinColumn(nullable: false)] private ?Restaurant $restaurant = null; - public function getId(): ?int + public function getId(): ?Uuid { return $this->id; } diff --git a/src/Entity/News.php b/src/Entity/News.php index a4de9af..2f61753 100644 --- a/src/Entity/News.php +++ b/src/Entity/News.php @@ -22,10 +22,10 @@ class News #[ORM\Column] private ?bool $active = null; - #[ORM\Column(type: Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] private ?\DateTimeInterface $createAt = null; - #[ORM\Column(type: Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] private ?\DateTimeInterface $updateAt = null; #[ORM\Column] @@ -56,6 +56,10 @@ class News #[ORM\ManyToMany(targetEntity: NewsCategory::class)] private Collection $newsCategories; + #[ORM\ManyToOne] + #[ORM\JoinColumn(nullable: false)] + private ?Seo $seo = null; + public function __construct() { $this->newsCategories = new ArrayCollection(); @@ -221,4 +225,16 @@ class News return $this; } + + public function getSeo(): ?Seo + { + return $this->seo; + } + + public function setSeo(?Seo $seo): static + { + $this->seo = $seo; + + return $this; + } } diff --git a/src/Entity/NewsCategory.php b/src/Entity/NewsCategory.php index 974a99c..1322e29 100644 --- a/src/Entity/NewsCategory.php +++ b/src/Entity/NewsCategory.php @@ -49,31 +49,4 @@ class NewsCategory return $this; } - - /** - * @return Collection - */ - public function getNews(): Collection - { - return $this->news; - } - - public function addNews(News $news): static - { - if (!$this->news->contains($news)) { - $this->news->add($news); - $news->addNewsCategory($this); - } - - return $this; - } - - public function removeNews(News $news): static - { - if ($this->news->removeElement($news)) { - $news->removeNewsCategory($this); - } - - return $this; - } } diff --git a/src/Entity/NewsComment.php b/src/Entity/NewsComment.php index 44f0e48..683c324 100644 --- a/src/Entity/NewsComment.php +++ b/src/Entity/NewsComment.php @@ -5,14 +5,14 @@ namespace App\Entity; use App\Repository\NewsCommentRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: NewsCommentRepository::class)] class NewsComment { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; + #[ORM\Column(type: 'uuid', unique: true)] + private ?Uuid $id = null; #[ORM\OneToOne(cascade: ['persist', 'remove'])] #[ORM\JoinColumn(nullable: false)] @@ -35,13 +35,13 @@ class NewsComment #[ORM\Column(length: 255)] private ?string $text = null; - #[ORM\Column(type: Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] private ?\DateTimeInterface $createAt = null; - #[ORM\Column(type: Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] private ?\DateTimeImmutable $updateAt = null; - public function getId(): ?int + public function getId(): ?Uuid { return $this->id; } diff --git a/src/Entity/NewsType.php b/src/Entity/NewsType.php index 409ac09..27b05d3 100644 --- a/src/Entity/NewsType.php +++ b/src/Entity/NewsType.php @@ -6,14 +6,14 @@ use App\Repository\NewsTypeRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: NewsTypeRepository::class)] class NewsType { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; + #[ORM\Column(type: 'uuid', unique: true)] + private ?Uuid $id = null; #[ORM\Column(length: 255)] private ?string $name = null; @@ -29,7 +29,7 @@ class NewsType $this->news = new ArrayCollection(); } - public function getId(): ?int + public function getId(): ?Uuid { return $this->id; } diff --git a/src/Entity/Restaurant.php b/src/Entity/Restaurant.php index 02fd3b1..304e779 100644 --- a/src/Entity/Restaurant.php +++ b/src/Entity/Restaurant.php @@ -13,12 +13,8 @@ use Symfony\Component\Uid\Uuid; class Restaurant { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; - #[ORM\Column(type: 'uuid', unique: true)] - private ?Uuid $uuid = null; + private ?Uuid $id = null; #[ORM\Column(length: 255)] private ?string $name = null; @@ -32,13 +28,13 @@ class Restaurant #[ORM\Column] private ?int $sort = null; - #[ORM\Column(type: Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] private ?\DateTimeInterface $createAt = null; - #[ORM\Column(type: Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] private ?\DateTimeInterface $updateAt = null; - #[ORM\Column(type: Types::ARRAY)] + #[ORM\Column(type: 'simple_array')] private array $coordinates = []; #[ORM\ManyToOne(inversedBy: 'restaurants')] @@ -64,22 +60,13 @@ class Restaurant #[ORM\OneToMany(targetEntity: Kitchen::class, mappedBy: 'restaurant')] private Collection $kitchen; - /** - * @var Collection - */ - #[ORM\OneToMany(targetEntity: Phone::class, mappedBy: 'restaurant')] + #[ORM\Column(type: Types::JSON)] private Collection $phone; - /** - * @var Collection - */ - #[ORM\OneToMany(targetEntity: Email::class, mappedBy: 'restaurant')] + #[ORM\Column(type: Types::JSON)] private Collection $email; - /** - * @var Collection - */ - #[ORM\OneToMany(targetEntity: Address::class, mappedBy: 'restaurant')] + #[ORM\Column(type: Types::JSON)] private Collection $address; /** @@ -100,6 +87,16 @@ 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; + public function __construct() { $this->kitchen = new ArrayCollection(); @@ -107,25 +104,14 @@ class Restaurant $this->email = new ArrayCollection(); $this->address = new ArrayCollection(); $this->tags = new ArrayCollection(); + $this->galleries = new ArrayCollection(); } - public function getId(): ?int + public function getId(): ?Uuid { return $this->id; } - public function getUuid(): ?Uuid - { - return $this->uuid; - } - - public function setUuid(Uuid $uuid): static - { - $this->uuid = $uuid; - - return $this; - } - public function getName(): ?string { return $this->name; @@ -467,4 +453,46 @@ 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; + } + + public function setSeo(?Seo $seo): static + { + $this->seo = $seo; + + return $this; + } } diff --git a/src/Entity/RestaurantType.php b/src/Entity/RestaurantType.php index 2698a85..eb59ef7 100644 --- a/src/Entity/RestaurantType.php +++ b/src/Entity/RestaurantType.php @@ -6,14 +6,14 @@ use App\Repository\RestaurantTypeRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: RestaurantTypeRepository::class)] class RestaurantType { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; + #[ORM\Column(type: 'uuid', unique: true)] + private ?Uuid $id = null; #[ORM\Column(length: 255)] private ?string $name = null; @@ -32,7 +32,7 @@ class RestaurantType $this->restaurants = new ArrayCollection(); } - public function getId(): ?int + public function getId(): ?Uuid { return $this->id; } diff --git a/src/Entity/Seo.php b/src/Entity/Seo.php new file mode 100644 index 0000000..8d4328f --- /dev/null +++ b/src/Entity/Seo.php @@ -0,0 +1,65 @@ +id; + } + + public function getTitle(): ?string + { + return $this->title; + } + + public function setTitle(string $title): static + { + $this->title = $title; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(string $description): static + { + $this->description = $description; + + return $this; + } + + public function getKeywords(): ?string + { + return $this->keywords; + } + + public function setKeywords(string $keywords): static + { + $this->keywords = $keywords; + + return $this; + } +} diff --git a/src/Entity/Settlement.php b/src/Entity/Settlement.php index 9f983df..94d8e4d 100644 --- a/src/Entity/Settlement.php +++ b/src/Entity/Settlement.php @@ -13,12 +13,8 @@ use Symfony\Component\Uid\Uuid; class Settlement { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; - #[ORM\Column(type: 'uuid', unique: true)] - private ?Uuid $uuid = null; + private ?Uuid $id = null; #[ORM\Column(length: 255)] private ?string $name = null; @@ -29,10 +25,10 @@ class Settlement #[ORM\Column(type: Types::ARRAY)] private array $coordinates = []; - #[ORM\Column(type: Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] private ?\DateTimeInterface $createAt = null; - #[ORM\Column(type: Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] private ?\DateTimeInterface $updateAt = null; /** @@ -46,23 +42,11 @@ class Settlement $this->restaurants = new ArrayCollection(); } - public function getId(): ?int + public function getId(): ?Uuid { return $this->id; } - public function getUuid(): ?Uuid - { - return $this->uuid; - } - - public function setUuid(Uuid $uuid): static - { - $this->uuid = $uuid; - - return $this; - } - public function getName(): ?string { return $this->name; diff --git a/src/Entity/Tags.php b/src/Entity/Tags.php index 34514ad..a52ff23 100644 --- a/src/Entity/Tags.php +++ b/src/Entity/Tags.php @@ -3,15 +3,16 @@ namespace App\Entity; use App\Repository\TagsRepository; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: TagsRepository::class)] class Tags { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; + #[ORM\Column(type: 'uuid', unique: true)] + private ?Uuid $id = null; #[ORM\Column(length: 255)] private ?string $name = null; @@ -20,7 +21,10 @@ class Tags #[ORM\JoinColumn(nullable: false)] private ?Restaurant $restaurant = null; - public function getId(): ?int + #[ORM\Column(type: 'simple_array')] + private array $list = []; + + public function getId(): ?Uuid { return $this->id; } @@ -48,4 +52,16 @@ class Tags return $this; } + + public function getList(): array + { + return $this->list; + } + + public function setList(array $list): static + { + $this->list = $list; + + return $this; + } } diff --git a/src/Entity/User.php b/src/Entity/User.php index 7f1d85e..208382f 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -13,9 +13,8 @@ use Symfony\Component\Uid\Uuid; class User { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; + #[ORM\Column(type: 'uuid', unique: true)] + private ?Uuid $id = null; #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $uuid = null; @@ -34,23 +33,11 @@ class User $this->newsComments = new ArrayCollection(); } - public function getId(): ?int + public function getId(): ?Uuid { return $this->id; } - public function getUuid(): ?Uuid - { - return $this->uuid; - } - - public function setUuid(Uuid $uuid): static - { - $this->uuid = $uuid; - - return $this; - } - public function getName(): ?string { return $this->name; diff --git a/src/Repository/AddressRepository.php b/src/Repository/AddressRepository.php deleted file mode 100644 index e87117f..0000000 --- a/src/Repository/AddressRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method Address|null find($id, $lockMode = null, $lockVersion = null) - * @method Address|null findOneBy(array $criteria, array $orderBy = null) - * @method Address[] findAll() - * @method Address[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class AddressRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, Address::class); - } - -// /** -// * @return Address[] Returns an array of Address objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('a') -// ->andWhere('a.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('a.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } - -// public function findOneBySomeField($value): ?Address -// { -// return $this->createQueryBuilder('a') -// ->andWhere('a.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Repository/EmailRepository.php b/src/Repository/EmailRepository.php deleted file mode 100644 index f22b0ee..0000000 --- a/src/Repository/EmailRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method Email|null find($id, $lockMode = null, $lockVersion = null) - * @method Email|null findOneBy(array $criteria, array $orderBy = null) - * @method Email[] findAll() - * @method Email[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class EmailRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, Email::class); - } - -// /** -// * @return Email[] Returns an array of Email objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('e') -// ->andWhere('e.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('e.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } - -// public function findOneBySomeField($value): ?Email -// { -// return $this->createQueryBuilder('e') -// ->andWhere('e.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Repository/FileRepository.php b/src/Repository/FileRepository.php new file mode 100644 index 0000000..4d5449a --- /dev/null +++ b/src/Repository/FileRepository.php @@ -0,0 +1,48 @@ + + * + * @method File|null find($id, $lockMode = null, $lockVersion = null) + * @method File|null findOneBy(array $criteria, array $orderBy = null) + * @method File[] findAll() + * @method File[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class FileRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, File::class); + } + +// /** +// * @return File[] Returns an array of File objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('f') +// ->andWhere('f.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('f.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?File +// { +// return $this->createQueryBuilder('f') +// ->andWhere('f.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/GalleryRepository.php b/src/Repository/GalleryRepository.php new file mode 100644 index 0000000..d15e89a --- /dev/null +++ b/src/Repository/GalleryRepository.php @@ -0,0 +1,48 @@ + + * + * @method Gallery|null find($id, $lockMode = null, $lockVersion = null) + * @method Gallery|null findOneBy(array $criteria, array $orderBy = null) + * @method Gallery[] findAll() + * @method Gallery[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class GalleryRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Gallery::class); + } + +// /** +// * @return Gallery[] Returns an array of Gallery objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('g') +// ->andWhere('g.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('g.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Gallery +// { +// return $this->createQueryBuilder('g') +// ->andWhere('g.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/src/Repository/PhoneRepository.php b/src/Repository/PhoneRepository.php deleted file mode 100644 index de389d6..0000000 --- a/src/Repository/PhoneRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method Phone|null find($id, $lockMode = null, $lockVersion = null) - * @method Phone|null findOneBy(array $criteria, array $orderBy = null) - * @method Phone[] findAll() - * @method Phone[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class PhoneRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, Phone::class); - } - -// /** -// * @return Phone[] Returns an array of Phone objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('p') -// ->andWhere('p.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('p.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } - -// public function findOneBySomeField($value): ?Phone -// { -// return $this->createQueryBuilder('p') -// ->andWhere('p.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Repository/SeoRepository.php b/src/Repository/SeoRepository.php new file mode 100644 index 0000000..09b0990 --- /dev/null +++ b/src/Repository/SeoRepository.php @@ -0,0 +1,48 @@ + + * + * @method Seo|null find($id, $lockMode = null, $lockVersion = null) + * @method Seo|null findOneBy(array $criteria, array $orderBy = null) + * @method Seo[] findAll() + * @method Seo[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class SeoRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Seo::class); + } + +// /** +// * @return Seo[] Returns an array of Seo objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('s.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Seo +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/tests/RestaurantControllerTest.php b/tests/RestaurantControllerTest.php new file mode 100644 index 0000000..c976e59 --- /dev/null +++ b/tests/RestaurantControllerTest.php @@ -0,0 +1,63 @@ +request('GET', '/api/v1/restaurants?page=1&limit=12'); + $actual = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); + $expect = '{ + "pagination": { + "currentPage": 1, + "pages": 1, + "pageSize": 12 + }, + "list": [ + { + "id": 1, + "name": "Ресторан «Арктика»", + "code": "restoran-arktika", + "type": { + "id": 1, + "name": "Ресторан", + "code": "restoran" + }, + "check": "bla bla", + "image": { + "id": 1, + "name": "name", + "description": "description", + "size": 10, + "type": "jpg", + "url": "/upload/preview.png" + }, + "detailLink": "https://visityamal.ru/" + } + ], + "filterVariants": { + "type": [ + { + "id": 1, + "name": "Ресторан", + "code": "restoran" + } + ], + "kitchen": [ + { + "id": 1, + "name": "Азиатская" + } + ] + } +}'; + self::assertResponseIsSuccessful(); + self::assertJsonStringEqualsJsonString($expect, $actual); + } +} -- GitLab From 636fdb6e56052bea01f660b5a35e1c33e5b145d6 Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Thu, 2 May 2024 13:00:14 +0500 Subject: [PATCH 06/11] =?UTF-8?q?STA-965=20|=20=D0=9D=D0=B5=D0=B1=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D1=88=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- docker-compose.yaml | 5 +- migrations/Version20240502075531.php | 156 +++++++++++++++++++++++++++ src/Entity/Seo.php | 8 +- 4 files changed, 163 insertions(+), 8 deletions(-) create mode 100644 migrations/Version20240502075531.php diff --git a/.env b/.env index 988a069..8c34a32 100644 --- a/.env +++ b/.env @@ -39,7 +39,7 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 ###> symfony/mailer ### # MAILER_DSN=null://null ###< symfony/mailer ### -DATABASE_PORT="5432" +DATABASE_PORT="5433" NGINX_PORT="80" APP_BASE_DIR="./" POSTGRES_USER="postgres" diff --git a/docker-compose.yaml b/docker-compose.yaml index b41d486..a4e3a36 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,7 +9,7 @@ services: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_HOST_AUTH_METHOD: trust ports: - - "${DATABASE_PORT}:${DATABASE_PORT}" + - "${DATABASE_PORT}:5432" networks: - internal nginx: @@ -20,9 +20,8 @@ services: APP_BASE_DIR: ${APP_BASE_DIR-.} volumes: - ".:/app" - - './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf' ports: - - '${NGINX_PORT}:${NGINX_PORT}' + - '${NGINX_PORT}:80' networks: - internal app: diff --git a/migrations/Version20240502075531.php b/migrations/Version20240502075531.php new file mode 100644 index 0000000..0a37630 --- /dev/null +++ b/migrations/Version20240502075531.php @@ -0,0 +1,156 @@ +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('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 UNIQUE INDEX UNIQ_472B783A93CB796C ON gallery (file_id)'); + $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 INDEX IDX_1DD39950C54C8C93 ON news (type_id)'); + $this->addSql('CREATE INDEX IDX_1DD3995097E3DD86 ON news (seo_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.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))'); + $this->addSql('CREATE INDEX IDX_1A91D6D6B5A459A0 ON news_news_category (news_id)'); + $this->addSql('CREATE INDEX IDX_1A91D6D63B732BAD ON news_news_category (news_category_id)'); + $this->addSql('COMMENT ON COLUMN news_news_category.news_id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN news_news_category.news_category_id IS \'(DC2Type:uuid)\''); + $this->addSql('CREATE TABLE news_category (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('COMMENT ON COLUMN news_category.id IS \'(DC2Type:uuid)\''); + $this->addSql('CREATE TABLE news_comment (id UUID NOT NULL, news_id_id UUID NOT NULL, moderator_id_id UUID NOT NULL, user_id_id UUID NOT NULL, moderated BOOLEAN NOT NULL, user_name VARCHAR(255) NOT NULL, text VARCHAR(255) 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('CREATE UNIQUE INDEX UNIQ_C3904E8A5FB1909 ON news_comment (news_id_id)'); + $this->addSql('CREATE INDEX IDX_C3904E8ACEB712DF ON news_comment (moderator_id_id)'); + $this->addSql('CREATE INDEX IDX_C3904E8A9D86650F ON news_comment (user_id_id)'); + $this->addSql('COMMENT ON COLUMN news_comment.id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN news_comment.news_id_id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN news_comment.moderator_id_id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN news_comment.user_id_id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN news_comment.create_at IS \'(DC2Type:datetime_immutable)\''); + $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 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('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.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 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)\''); + $this->addSql('COMMENT ON COLUMN settlement.create_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN settlement.update_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('CREATE TABLE tags (id UUID NOT NULL, restaurant_id UUID NOT NULL, name VARCHAR(255) NOT NULL, list TEXT NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_6FBC9426B1E7706E ON tags (restaurant_id)'); + $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('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)'); + $this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)'); + $this->addSql('COMMENT ON COLUMN messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$ + BEGIN + PERFORM pg_notify(\'messenger_messages\', NEW.queue_name::text); + RETURN NEW; + END; + $$ LANGUAGE plpgsql;'); + $this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;'); + $this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();'); + $this->addSql('ALTER TABLE gallery ADD CONSTRAINT FK_472B783AB1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE gallery ADD CONSTRAINT FK_472B783A93CB796C FOREIGN KEY (file_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $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_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'); + $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8ACEB712DF FOREIGN KEY (moderator_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE news_comment ADD CONSTRAINT FK_C3904E8A9D86650F FOREIGN KEY (user_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $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 tags ADD CONSTRAINT FK_6FBC9426B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + // 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('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_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'); + $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8ACEB712DF'); + $this->addSql('ALTER TABLE news_comment DROP CONSTRAINT FK_C3904E8A9D86650F'); + $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 tags DROP CONSTRAINT FK_6FBC9426B1E7706E'); + $this->addSql('DROP TABLE file'); + $this->addSql('DROP TABLE gallery'); + $this->addSql('DROP TABLE kitchen'); + $this->addSql('DROP TABLE news'); + $this->addSql('DROP TABLE news_news_category'); + $this->addSql('DROP TABLE news_category'); + $this->addSql('DROP TABLE news_comment'); + $this->addSql('DROP TABLE news_type'); + $this->addSql('DROP TABLE restaurant'); + $this->addSql('DROP TABLE restaurant_type'); + $this->addSql('DROP TABLE seo'); + $this->addSql('DROP TABLE settlement'); + $this->addSql('DROP TABLE tags'); + $this->addSql('DROP TABLE "user"'); + $this->addSql('DROP TABLE messenger_messages'); + } +} diff --git a/src/Entity/Seo.php b/src/Entity/Seo.php index 8d4328f..e68bb30 100644 --- a/src/Entity/Seo.php +++ b/src/Entity/Seo.php @@ -4,14 +4,14 @@ namespace App\Entity; use App\Repository\SeoRepository; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: SeoRepository::class)] class Seo { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; + #[ORM\Column(type: 'uuid', unique: true)] + private ?Uuid $id = null; #[ORM\Column(length: 255)] private ?string $title = null; @@ -22,7 +22,7 @@ class Seo #[ORM\Column(length: 255)] private ?string $keywords = null; - public function getId(): ?int + public function getId(): ?Uuid { return $this->id; } -- GitLab From 2e6c717d88431ccf40778c83e77c0056308c32fd Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Thu, 2 May 2024 13:18:26 +0500 Subject: [PATCH 07/11] =?UTF-8?q?STA-965=20|=20=D0=9F=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=20uuid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Entity/File.php | 1 + src/Entity/Gallery.php | 5 +- src/Entity/Kitchen.php | 1 + src/Entity/News.php | 1 + src/Entity/NewsCategory.php | 1 + src/Entity/NewsComment.php | 1 + src/Entity/NewsType.php | 1 + src/Entity/Restaurant.php | 127 ++++++++-------------------------- src/Entity/RestaurantType.php | 1 + src/Entity/Seo.php | 1 + src/Entity/Settlement.php | 1 + src/Entity/Tags.php | 1 + src/Entity/User.php | 1 + 13 files changed, 42 insertions(+), 101 deletions(-) diff --git a/src/Entity/File.php b/src/Entity/File.php index 39432fc..712eb87 100644 --- a/src/Entity/File.php +++ b/src/Entity/File.php @@ -10,6 +10,7 @@ use Symfony\Component\Uid\Uuid; class File { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/Gallery.php b/src/Entity/Gallery.php index 1edce96..05dd42a 100644 --- a/src/Entity/Gallery.php +++ b/src/Entity/Gallery.php @@ -4,14 +4,15 @@ namespace App\Entity; use App\Repository\GalleryRepository; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: GalleryRepository::class)] class Gallery { #[ORM\Id] #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; + #[ORM\Column(type: 'uuid', unique: true)] + private ?Uuid $id = null; #[ORM\ManyToOne(inversedBy: 'galleries')] #[ORM\JoinColumn(nullable: false)] diff --git a/src/Entity/Kitchen.php b/src/Entity/Kitchen.php index 0315324..91a71a3 100644 --- a/src/Entity/Kitchen.php +++ b/src/Entity/Kitchen.php @@ -10,6 +10,7 @@ use Symfony\Component\Uid\Uuid; class Kitchen { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/News.php b/src/Entity/News.php index 2f61753..3a57eb3 100644 --- a/src/Entity/News.php +++ b/src/Entity/News.php @@ -13,6 +13,7 @@ use Symfony\Component\Uid\Uuid; class News { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/NewsCategory.php b/src/Entity/NewsCategory.php index 1322e29..7fbe56b 100644 --- a/src/Entity/NewsCategory.php +++ b/src/Entity/NewsCategory.php @@ -12,6 +12,7 @@ use Symfony\Component\Uid\Uuid; class NewsCategory { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/NewsComment.php b/src/Entity/NewsComment.php index 683c324..46c066d 100644 --- a/src/Entity/NewsComment.php +++ b/src/Entity/NewsComment.php @@ -11,6 +11,7 @@ use Symfony\Component\Uid\Uuid; class NewsComment { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/NewsType.php b/src/Entity/NewsType.php index 27b05d3..abd94e1 100644 --- a/src/Entity/NewsType.php +++ b/src/Entity/NewsType.php @@ -12,6 +12,7 @@ use Symfony\Component\Uid\Uuid; class NewsType { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/Restaurant.php b/src/Entity/Restaurant.php index 304e779..f3fa475 100644 --- a/src/Entity/Restaurant.php +++ b/src/Entity/Restaurant.php @@ -13,6 +13,7 @@ use Symfony\Component\Uid\Uuid; class Restaurant { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; @@ -60,14 +61,14 @@ class Restaurant #[ORM\OneToMany(targetEntity: Kitchen::class, mappedBy: 'restaurant')] private Collection $kitchen; - #[ORM\Column(type: Types::JSON)] - private Collection $phone; + #[ORM\Column] + private array $phone = []; - #[ORM\Column(type: Types::JSON)] - private Collection $email; + #[ORM\Column] + private array $email = []; - #[ORM\Column(type: Types::JSON)] - private Collection $address; + #[ORM\Column] + private array $address = []; /** * @var Collection @@ -100,9 +101,6 @@ class Restaurant public function __construct() { $this->kitchen = new ArrayCollection(); - $this->phone = new ArrayCollection(); - $this->email = new ArrayCollection(); - $this->address = new ArrayCollection(); $this->tags = new ArrayCollection(); $this->galleries = new ArrayCollection(); } @@ -286,96 +284,6 @@ class Restaurant return $this; } - /** - * @return Collection - */ - public function getPhone(): Collection - { - return $this->phone; - } - - public function addPhone(Phone $phone): static - { - if (!$this->phone->contains($phone)) { - $this->phone->add($phone); - $phone->setRestaurant($this); - } - - return $this; - } - - public function removePhone(Phone $phone): static - { - if ($this->phone->removeElement($phone)) { - // set the owning side to null (unless already changed) - if ($phone->getRestaurant() === $this) { - $phone->setRestaurant(null); - } - } - - return $this; - } - - /** - * @return Collection - */ - public function getEmail(): Collection - { - return $this->email; - } - - public function addEmail(Email $email): static - { - if (!$this->email->contains($email)) { - $this->email->add($email); - $email->setRestaurant($this); - } - - return $this; - } - - public function removeEmail(Email $email): static - { - if ($this->email->removeElement($email)) { - // set the owning side to null (unless already changed) - if ($email->getRestaurant() === $this) { - $email->setRestaurant(null); - } - } - - return $this; - } - - /** - * @return Collection - */ - public function getAddress(): Collection - { - return $this->address; - } - - public function addAddress(Address $address): static - { - if (!$this->address->contains($address)) { - $this->address->add($address); - $address->setRestaurant($this); - } - - return $this; - } - - public function removeAddress(Address $address): static - { - if ($this->address->removeElement($address)) { - // set the owning side to null (unless already changed) - if ($address->getRestaurant() === $this) { - $address->setRestaurant(null); - } - } - - return $this; - } - /** * @return Collection */ @@ -495,4 +403,25 @@ class Restaurant return $this; } + + public function setPhone(array $phone): static + { + $this->phone = $phone; + + return $this; + } + + public function setEmail(array $email): static + { + $this->email = $email; + + return $this; + } + + public function setAddress(array $address): static + { + $this->address = $address; + + return $this; + } } diff --git a/src/Entity/RestaurantType.php b/src/Entity/RestaurantType.php index eb59ef7..447b0ee 100644 --- a/src/Entity/RestaurantType.php +++ b/src/Entity/RestaurantType.php @@ -12,6 +12,7 @@ use Symfony\Component\Uid\Uuid; class RestaurantType { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/Seo.php b/src/Entity/Seo.php index e68bb30..59d2140 100644 --- a/src/Entity/Seo.php +++ b/src/Entity/Seo.php @@ -10,6 +10,7 @@ use Symfony\Component\Uid\Uuid; class Seo { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/Settlement.php b/src/Entity/Settlement.php index 94d8e4d..b6cb733 100644 --- a/src/Entity/Settlement.php +++ b/src/Entity/Settlement.php @@ -13,6 +13,7 @@ use Symfony\Component\Uid\Uuid; class Settlement { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/Tags.php b/src/Entity/Tags.php index a52ff23..03c7186 100644 --- a/src/Entity/Tags.php +++ b/src/Entity/Tags.php @@ -11,6 +11,7 @@ use Symfony\Component\Uid\Uuid; class Tags { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; diff --git a/src/Entity/User.php b/src/Entity/User.php index 208382f..1939b59 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -13,6 +13,7 @@ use Symfony\Component\Uid\Uuid; class User { #[ORM\Id] + #[ORM\GeneratedValue] #[ORM\Column(type: 'uuid', unique: true)] private ?Uuid $id = null; -- GitLab From 1470e5cbe419f63a028f4f32898405abae09a267 Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Thu, 2 May 2024 13:43:06 +0500 Subject: [PATCH 08/11] =?UTF-8?q?STA-965=20|=20=D0=9F=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20Gallery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Entity/Gallery.php | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Entity/Gallery.php b/src/Entity/Gallery.php index 05dd42a..7f1c5f3 100644 --- a/src/Entity/Gallery.php +++ b/src/Entity/Gallery.php @@ -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; @@ -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 + */ + #[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 ?File $file = null; - public function getId(): ?int + public function getId(): ?Uuid { return $this->id; } - public function getRestaurant(): ?Restaurant + /** + * @return Collection + */ + 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; + if (!$this->files->contains($file)) { + $this->files->add($file); + } return $this; } - public function getFile(): ?File - { - return $this->file; - } - - public function setFile(File $file): static + public function removeFile(File $file): static { - $this->file = $file; + $this->files->removeElement($file); return $this; } -- GitLab From 9194791cb3ea38c188c33ed358f9e81e8f51ab28 Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Thu, 2 May 2024 13:46:14 +0500 Subject: [PATCH 09/11] =?UTF-8?q?STA-965=20|=20=D0=9F=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20Restaurant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Entity/Restaurant.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Entity/Restaurant.php b/src/Entity/Restaurant.php index f3fa475..37d2318 100644 --- a/src/Entity/Restaurant.php +++ b/src/Entity/Restaurant.php @@ -98,6 +98,10 @@ class Restaurant #[ORM\JoinColumn(nullable: false)] private ?Seo $seo = null; + #[ORM\OneToOne(cascade: ['persist', 'remove'])] + #[ORM\JoinColumn(nullable: false)] + private ?File $file = null; + public function __construct() { $this->kitchen = new ArrayCollection(); @@ -424,4 +428,16 @@ class Restaurant return $this; } + + public function getFile(): ?File + { + return $this->file; + } + + public function setFile(File $file): static + { + $this->file = $file; + + return $this; + } } -- GitLab From 3b6f33a4f7362fcf6ae20a3586685b27effc0a05 Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Thu, 2 May 2024 13:51:41 +0500 Subject: [PATCH 10/11] =?UTF-8?q?STA-965=20|=20=D0=9F=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20News?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Entity/News.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Entity/News.php b/src/Entity/News.php index 3a57eb3..899f569 100644 --- a/src/Entity/News.php +++ b/src/Entity/News.php @@ -61,6 +61,10 @@ class News #[ORM\JoinColumn(nullable: false)] private ?Seo $seo = null; + #[ORM\OneToOne(cascade: ['persist', 'remove'])] + #[ORM\JoinColumn(nullable: false)] + private ?File $file = null; + public function __construct() { $this->newsCategories = new ArrayCollection(); @@ -238,4 +242,16 @@ class News return $this; } + + public function getFile(): ?File + { + return $this->file; + } + + public function setFile(File $file): static + { + $this->file = $file; + + return $this; + } } -- GitLab From b1b45cc944d75dfec3e1f5fe00d51c646be6d4aa Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Thu, 2 May 2024 14:50:18 +0500 Subject: [PATCH 11/11] =?UTF-8?q?STA-965=20|=20=D0=9F=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=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