From 4ce7dc6d9074b158b368c62ed8cbd7716e47a51b Mon Sep 17 00:00:00 2001 From: timur Date: Wed, 24 Jan 2018 02:08:13 +0200 Subject: [PATCH] миграции для объектов кб энерджи --- console/migrations/m180123_145850_create_object_table.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/m180123_222751_create_object_category_table.php | 29 +++++++++++++++++++++++++++++ console/migrations/m180123_224233_create_object_category_lang_table.php | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/m180123_231847_create_junction_table_for_object_and_object_category_tables.php | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/m180123_234322_create_object_lang_table.php | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/m180124_000452_add_image_mini_id_column_to_object_table.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/controllers/SiteController.php | 37 ++++++++++++++++++++++++++++++------- frontend/views/site/objects.php | 54 +++++++++++++++++++++++++++++++++--------------------- 8 files changed, 586 insertions(+), 28 deletions(-) create mode 100644 console/migrations/m180123_145850_create_object_table.php create mode 100644 console/migrations/m180123_222751_create_object_category_table.php create mode 100644 console/migrations/m180123_224233_create_object_category_lang_table.php create mode 100644 console/migrations/m180123_231847_create_junction_table_for_object_and_object_category_tables.php create mode 100644 console/migrations/m180123_234322_create_object_lang_table.php create mode 100644 console/migrations/m180124_000452_add_image_mini_id_column_to_object_table.php diff --git a/console/migrations/m180123_145850_create_object_table.php b/console/migrations/m180123_145850_create_object_table.php new file mode 100644 index 0000000..2ccf0bc --- /dev/null +++ b/console/migrations/m180123_145850_create_object_table.php @@ -0,0 +1,62 @@ +createTable('object', [ + 'id' => $this->primaryKey(), + 'slider_id' => $this->integer()->notNull(), + 'status' => $this->boolean(), + 'sort' => $this->integer(), + ]); + + // creates index for column `slider_id` + $this->createIndex( + 'idx-object-slider_id', + 'object', + 'slider_id' + ); + + // add foreign key for table `slider` + $this->addForeignKey( + 'fk-object-slider_id', + 'object', + 'slider_id', + 'slider', + 'id', + 'CASCADE' + ); + } + + /** + * @inheritdoc + */ + public function down() + { + // drops foreign key for table `slider` + $this->dropForeignKey( + 'fk-object-slider_id', + 'object' + ); + + // drops index for column `slider_id` + $this->dropIndex( + 'idx-object-slider_id', + 'object' + ); + + $this->dropTable('object'); + } +} diff --git a/console/migrations/m180123_222751_create_object_category_table.php b/console/migrations/m180123_222751_create_object_category_table.php new file mode 100644 index 0000000..ec9fba0 --- /dev/null +++ b/console/migrations/m180123_222751_create_object_category_table.php @@ -0,0 +1,29 @@ +createTable('object_category', [ + 'id' => $this->primaryKey(), + 'sort' => $this->integer(), + 'status' => $this->boolean(), + ]); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropTable('object_category'); + } +} diff --git a/console/migrations/m180123_224233_create_object_category_lang_table.php b/console/migrations/m180123_224233_create_object_category_lang_table.php new file mode 100644 index 0000000..ba641e5 --- /dev/null +++ b/console/migrations/m180123_224233_create_object_category_lang_table.php @@ -0,0 +1,141 @@ +createTable('object_category_lang', [ + 'object_category_id' => $this->integer()->notNull(), + 'language_id' => $this->integer()->notNull(), + 'object_category_name' => $this->string(50), + 'alias_id' => $this->integer()->notNull()->unique(), + 'meta_title' => $this->string(300), + 'meta_description' => $this->string(300), + 'h1' => $this->string(50), + ]); + + // creates index for column `object_category_id` + $this->createIndex( + 'idx-object_category_lang-object_category_id', + 'object_category_lang', + 'object_category_id' + ); + + // add foreign key for table `object_category` + $this->addForeignKey( + 'fk-object_category_lang-object_category_id', + 'object_category_lang', + 'object_category_id', + 'object_category', + 'id', + 'CASCADE' + ); + + // creates index for column `language_id` + $this->createIndex( + 'idx-object_category_lang-language_id', + 'object_category_lang', + 'language_id' + ); + + // add foreign key for table `language` + $this->addForeignKey( + 'fk-object_category_lang-language_id', + 'object_category_lang', + 'language_id', + 'language', + 'id', + 'CASCADE' + ); + + // creates index for column `alias_id` + $this->createIndex( + 'idx-object_category_lang-alias_id', + 'object_category_lang', + 'alias_id' + ); + + // add foreign key for table `alias` + $this->addForeignKey( + 'fk-object_category_lang-alias_id', + 'object_category_lang', + 'alias_id', + 'alias', + 'id', + 'CASCADE' + ); + + //add double primary key + $this->addPrimaryKey( + "pk-object_category_lang-object_category_id-language_id", + "object_category_lang", + [ + "object_category_id", + "language_id", + ] + ); + } + + /** + * @inheritdoc + */ + public function down() + { + // drop double primary key + $this->dropPrimaryKey( + "pk-object_category_lang-object_category_id-language_id", + "object_category_lang" + ); + + // drops foreign key for table `object_category` + $this->dropForeignKey( + 'fk-object_category_lang-object_category_id', + 'object_category_lang' + ); + + // drops index for column `object_category_id` + $this->dropIndex( + 'idx-object_category_lang-object_category_id', + 'object_category_lang' + ); + + // drops foreign key for table `language` + $this->dropForeignKey( + 'fk-object_category_lang-language_id', + 'object_category_lang' + ); + + // drops index for column `language_id` + $this->dropIndex( + 'idx-object_category_lang-language_id', + 'object_category_lang' + ); + + // drops foreign key for table `alias` + $this->dropForeignKey( + 'fk-object_category_lang-alias_id', + 'object_category_lang' + ); + + // drops index for column `alias_id` + $this->dropIndex( + 'idx-object_category_lang-alias_id', + 'object_category_lang' + ); + + $this->dropTable('object_category_lang'); + } +} diff --git a/console/migrations/m180123_231847_create_junction_table_for_object_and_object_category_tables.php b/console/migrations/m180123_231847_create_junction_table_for_object_and_object_category_tables.php new file mode 100644 index 0000000..83fc9ea --- /dev/null +++ b/console/migrations/m180123_231847_create_junction_table_for_object_and_object_category_tables.php @@ -0,0 +1,91 @@ +createTable('object_to_object_category', [ + 'object_id' => $this->integer(), + 'object_category_id' => $this->integer(), + 'PRIMARY KEY(object_id, object_category_id)', + ]); + + // creates index for column `object_id` + $this->createIndex( + 'idx-object_to_object_category-object_id', + 'object_to_object_category', + 'object_id' + ); + + // add foreign key for table `object` + $this->addForeignKey( + 'fk-object_to_object_category-object_id', + 'object_to_object_category', + 'object_id', + 'object', + 'id', + 'CASCADE' + ); + + // creates index for column `object_category_id` + $this->createIndex( + 'idx-object_to_object_category-object_category_id', + 'object_to_object_category', + 'object_category_id' + ); + + // add foreign key for table `object_category` + $this->addForeignKey( + 'fk-object_to_object_category-object_category_id', + 'object_to_object_category', + 'object_category_id', + 'object_category', + 'id', + 'CASCADE' + ); + } + + /** + * @inheritdoc + */ + public function down() + { + // drops foreign key for table `object` + $this->dropForeignKey( + 'fk-object_to_object_category-object_id', + 'object_to_object_category' + ); + + // drops index for column `object_id` + $this->dropIndex( + 'idx-object_to_object_category-object_id', + 'object_to_object_category' + ); + + // drops foreign key for table `object_category` + $this->dropForeignKey( + 'fk-object_to_object_category-object_category_id', + 'object_to_object_category' + ); + + // drops index for column `object_category_id` + $this->dropIndex( + 'idx-object_to_object_category-object_category_id', + 'object_to_object_category' + ); + + $this->dropTable('object_to_object_category'); + } +} diff --git a/console/migrations/m180123_234322_create_object_lang_table.php b/console/migrations/m180123_234322_create_object_lang_table.php new file mode 100644 index 0000000..025d392 --- /dev/null +++ b/console/migrations/m180123_234322_create_object_lang_table.php @@ -0,0 +1,143 @@ +createTable('object_lang', [ + 'object_id' => $this->integer()->notNull(), + 'language_id' => $this->integer()->notNull(), + 'alias_id' => $this->integer()->notNull()->unique(), + 'upper_text' => $this->text(), + 'about_object_text' => $this->text(), + 'object_name' => $this->string(50), + 'meta_title' => $this->string(300), + 'meta_description' => $this->string(300), + 'h1' => $this->string(50), + ]); + + // creates index for column `object_id` + $this->createIndex( + 'idx-object_lang-object_id', + 'object_lang', + 'object_id' + ); + + // add foreign key for table `object` + $this->addForeignKey( + 'fk-object_lang-object_id', + 'object_lang', + 'object_id', + 'object', + 'id', + 'CASCADE' + ); + + // creates index for column `language_id` + $this->createIndex( + 'idx-object_lang-language_id', + 'object_lang', + 'language_id' + ); + + // add foreign key for table `language` + $this->addForeignKey( + 'fk-object_lang-language_id', + 'object_lang', + 'language_id', + 'language', + 'id', + 'CASCADE' + ); + + // creates index for column `alias_id` + $this->createIndex( + 'idx-object_lang-alias_id', + 'object_lang', + 'alias_id' + ); + + // add foreign key for table `alias` + $this->addForeignKey( + 'fk-object_lang-alias_id', + 'object_lang', + 'alias_id', + 'alias', + 'id', + 'CASCADE' + ); + + // add double primary key + $this->addPrimaryKey( + "pk-object_lang-object_id-language_id", + "object_lang", + [ + "object_id", + "language_id", + ] + ); + } + + /** + * @inheritdoc + */ + public function down() + { + // drop double primary key + $this->dropPrimaryKey( + "pk-object_lang-object_id-language_id", + "object_lang" + ); + + // drops foreign key for table `object` + $this->dropForeignKey( + 'fk-object_lang-object_id', + 'object_lang' + ); + + // drops index for column `object_id` + $this->dropIndex( + 'idx-object_lang-object_id', + 'object_lang' + ); + + // drops foreign key for table `language` + $this->dropForeignKey( + 'fk-object_lang-language_id', + 'object_lang' + ); + + // drops index for column `language_id` + $this->dropIndex( + 'idx-object_lang-language_id', + 'object_lang' + ); + + // drops foreign key for table `alias` + $this->dropForeignKey( + 'fk-object_lang-alias_id', + 'object_lang' + ); + + // drops index for column `alias_id` + $this->dropIndex( + 'idx-object_lang-alias_id', + 'object_lang' + ); + + $this->dropTable('object_lang'); + } +} diff --git a/console/migrations/m180124_000452_add_image_mini_id_column_to_object_table.php b/console/migrations/m180124_000452_add_image_mini_id_column_to_object_table.php new file mode 100644 index 0000000..2a48271 --- /dev/null +++ b/console/migrations/m180124_000452_add_image_mini_id_column_to_object_table.php @@ -0,0 +1,57 @@ +addColumn('object', 'image_mini_id', $this->integer()->notNull()); + + // creates index for column `image_mini_id` + $this->createIndex( + 'idx-object-image_mini_id', + 'object', + 'image_mini_id' + ); + + // add foreign key for table `ImageManager` + $this->addForeignKey( + 'fk-object-image_mini_id', + 'object', + 'image_mini_id', + 'ImageManager', + 'id', + 'CASCADE' + ); + } + + /** + * @inheritdoc + */ + public function down() + { + // drops foreign key for table `ImageManager` + $this->dropForeignKey( + 'fk-object-image_mini_id', + 'object' + ); + + // drops index for column `image_mini_id` + $this->dropIndex( + 'idx-object-image_mini_id', + 'object' + ); + + $this->dropColumn('object', 'image_mini_id'); + } +} diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 3f03229..28ee218 100644 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -77,13 +77,36 @@ { return $this->render('about'); } - - public function actionIndividual(){return $this->render('individual');} // частное лицо - public function actionLegal(){return $this->render('legal');} // юридическое - public function actionObjects(){return $this->render('objects');} // наши объекты - public function actionGreen(){return $this->render('green');} // зелёный тариф - public function actionMediaAbout(){return $this->render('media-about');} // СМИ о нас - public function actionBlog(){return $this->render('blog');} // блог + + public function actionIndividual() + { + return $this->render('individual'); + } // частное лицо + + public function actionLegal() + { + return $this->render('legal'); + } // юридическое + + public function actionObjects() + { + return $this->render('objects'); + } // наши объекты + + public function actionGreen() + { + return $this->render('green'); + } // зелёный тариф + + public function actionMediaAbout() + { + return $this->render('media-about'); + } // СМИ о нас + + public function actionBlog() + { + return $this->render('blog'); + } // блог /** * Action to view robots.txt file dinamycli diff --git a/frontend/views/site/objects.php b/frontend/views/site/objects.php index 54ff75a..09110dd 100644 --- a/frontend/views/site/objects.php +++ b/frontend/views/site/objects.php @@ -21,9 +21,9 @@ $this->params[ 'breadcrumbs' ][] = $this->title;
- +
- +
- - +
- + +
- - + + - +
\ No newline at end of file -- libgit2 0.21.4