Commit 4ce7dc6d9074b158b368c62ed8cbd7716e47a51b
1 parent
87debd40
миграции для объектов кб энерджи
Showing
8 changed files
with
586 additions
and
28 deletions
Show diff stats
console/migrations/m180123_145850_create_object_table.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles the creation of table `object`. | |
7 | + * Has foreign keys to the tables: | |
8 | + * | |
9 | + * - `slider` | |
10 | + */ | |
11 | +class m180123_145850_create_object_table extends Migration | |
12 | +{ | |
13 | + /** | |
14 | + * @inheritdoc | |
15 | + */ | |
16 | + public function up() | |
17 | + { | |
18 | + $this->createTable('object', [ | |
19 | + 'id' => $this->primaryKey(), | |
20 | + 'slider_id' => $this->integer()->notNull(), | |
21 | + 'status' => $this->boolean(), | |
22 | + 'sort' => $this->integer(), | |
23 | + ]); | |
24 | + | |
25 | + // creates index for column `slider_id` | |
26 | + $this->createIndex( | |
27 | + 'idx-object-slider_id', | |
28 | + 'object', | |
29 | + 'slider_id' | |
30 | + ); | |
31 | + | |
32 | + // add foreign key for table `slider` | |
33 | + $this->addForeignKey( | |
34 | + 'fk-object-slider_id', | |
35 | + 'object', | |
36 | + 'slider_id', | |
37 | + 'slider', | |
38 | + 'id', | |
39 | + 'CASCADE' | |
40 | + ); | |
41 | + } | |
42 | + | |
43 | + /** | |
44 | + * @inheritdoc | |
45 | + */ | |
46 | + public function down() | |
47 | + { | |
48 | + // drops foreign key for table `slider` | |
49 | + $this->dropForeignKey( | |
50 | + 'fk-object-slider_id', | |
51 | + 'object' | |
52 | + ); | |
53 | + | |
54 | + // drops index for column `slider_id` | |
55 | + $this->dropIndex( | |
56 | + 'idx-object-slider_id', | |
57 | + 'object' | |
58 | + ); | |
59 | + | |
60 | + $this->dropTable('object'); | |
61 | + } | |
62 | +} | ... | ... |
console/migrations/m180123_222751_create_object_category_table.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles the creation of table `object_category`. | |
7 | + */ | |
8 | +class m180123_222751_create_object_category_table extends Migration | |
9 | +{ | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public function up() | |
14 | + { | |
15 | + $this->createTable('object_category', [ | |
16 | + 'id' => $this->primaryKey(), | |
17 | + 'sort' => $this->integer(), | |
18 | + 'status' => $this->boolean(), | |
19 | + ]); | |
20 | + } | |
21 | + | |
22 | + /** | |
23 | + * @inheritdoc | |
24 | + */ | |
25 | + public function down() | |
26 | + { | |
27 | + $this->dropTable('object_category'); | |
28 | + } | |
29 | +} | ... | ... |
console/migrations/m180123_224233_create_object_category_lang_table.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles the creation of table `object_category_lang`. | |
7 | + * Has foreign keys to the tables: | |
8 | + * | |
9 | + * - `object_category` | |
10 | + * - `language` | |
11 | + * - `alias` | |
12 | + */ | |
13 | +class m180123_224233_create_object_category_lang_table extends Migration | |
14 | +{ | |
15 | + /** | |
16 | + * @inheritdoc | |
17 | + */ | |
18 | + public function up() | |
19 | + { | |
20 | + $this->createTable('object_category_lang', [ | |
21 | + 'object_category_id' => $this->integer()->notNull(), | |
22 | + 'language_id' => $this->integer()->notNull(), | |
23 | + 'object_category_name' => $this->string(50), | |
24 | + 'alias_id' => $this->integer()->notNull()->unique(), | |
25 | + 'meta_title' => $this->string(300), | |
26 | + 'meta_description' => $this->string(300), | |
27 | + 'h1' => $this->string(50), | |
28 | + ]); | |
29 | + | |
30 | + // creates index for column `object_category_id` | |
31 | + $this->createIndex( | |
32 | + 'idx-object_category_lang-object_category_id', | |
33 | + 'object_category_lang', | |
34 | + 'object_category_id' | |
35 | + ); | |
36 | + | |
37 | + // add foreign key for table `object_category` | |
38 | + $this->addForeignKey( | |
39 | + 'fk-object_category_lang-object_category_id', | |
40 | + 'object_category_lang', | |
41 | + 'object_category_id', | |
42 | + 'object_category', | |
43 | + 'id', | |
44 | + 'CASCADE' | |
45 | + ); | |
46 | + | |
47 | + // creates index for column `language_id` | |
48 | + $this->createIndex( | |
49 | + 'idx-object_category_lang-language_id', | |
50 | + 'object_category_lang', | |
51 | + 'language_id' | |
52 | + ); | |
53 | + | |
54 | + // add foreign key for table `language` | |
55 | + $this->addForeignKey( | |
56 | + 'fk-object_category_lang-language_id', | |
57 | + 'object_category_lang', | |
58 | + 'language_id', | |
59 | + 'language', | |
60 | + 'id', | |
61 | + 'CASCADE' | |
62 | + ); | |
63 | + | |
64 | + // creates index for column `alias_id` | |
65 | + $this->createIndex( | |
66 | + 'idx-object_category_lang-alias_id', | |
67 | + 'object_category_lang', | |
68 | + 'alias_id' | |
69 | + ); | |
70 | + | |
71 | + // add foreign key for table `alias` | |
72 | + $this->addForeignKey( | |
73 | + 'fk-object_category_lang-alias_id', | |
74 | + 'object_category_lang', | |
75 | + 'alias_id', | |
76 | + 'alias', | |
77 | + 'id', | |
78 | + 'CASCADE' | |
79 | + ); | |
80 | + | |
81 | + //add double primary key | |
82 | + $this->addPrimaryKey( | |
83 | + "pk-object_category_lang-object_category_id-language_id", | |
84 | + "object_category_lang", | |
85 | + [ | |
86 | + "object_category_id", | |
87 | + "language_id", | |
88 | + ] | |
89 | + ); | |
90 | + } | |
91 | + | |
92 | + /** | |
93 | + * @inheritdoc | |
94 | + */ | |
95 | + public function down() | |
96 | + { | |
97 | + // drop double primary key | |
98 | + $this->dropPrimaryKey( | |
99 | + "pk-object_category_lang-object_category_id-language_id", | |
100 | + "object_category_lang" | |
101 | + ); | |
102 | + | |
103 | + // drops foreign key for table `object_category` | |
104 | + $this->dropForeignKey( | |
105 | + 'fk-object_category_lang-object_category_id', | |
106 | + 'object_category_lang' | |
107 | + ); | |
108 | + | |
109 | + // drops index for column `object_category_id` | |
110 | + $this->dropIndex( | |
111 | + 'idx-object_category_lang-object_category_id', | |
112 | + 'object_category_lang' | |
113 | + ); | |
114 | + | |
115 | + // drops foreign key for table `language` | |
116 | + $this->dropForeignKey( | |
117 | + 'fk-object_category_lang-language_id', | |
118 | + 'object_category_lang' | |
119 | + ); | |
120 | + | |
121 | + // drops index for column `language_id` | |
122 | + $this->dropIndex( | |
123 | + 'idx-object_category_lang-language_id', | |
124 | + 'object_category_lang' | |
125 | + ); | |
126 | + | |
127 | + // drops foreign key for table `alias` | |
128 | + $this->dropForeignKey( | |
129 | + 'fk-object_category_lang-alias_id', | |
130 | + 'object_category_lang' | |
131 | + ); | |
132 | + | |
133 | + // drops index for column `alias_id` | |
134 | + $this->dropIndex( | |
135 | + 'idx-object_category_lang-alias_id', | |
136 | + 'object_category_lang' | |
137 | + ); | |
138 | + | |
139 | + $this->dropTable('object_category_lang'); | |
140 | + } | |
141 | +} | ... | ... |
console/migrations/m180123_231847_create_junction_table_for_object_and_object_category_tables.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles the creation of table `object_to_object_category`. | |
7 | + * Has foreign keys to the tables: | |
8 | + * | |
9 | + * - `object` | |
10 | + * - `object_category` | |
11 | + */ | |
12 | +class m180123_231847_create_junction_table_for_object_and_object_category_tables extends Migration | |
13 | +{ | |
14 | + /** | |
15 | + * @inheritdoc | |
16 | + */ | |
17 | + public function up() | |
18 | + { | |
19 | + $this->createTable('object_to_object_category', [ | |
20 | + 'object_id' => $this->integer(), | |
21 | + 'object_category_id' => $this->integer(), | |
22 | + 'PRIMARY KEY(object_id, object_category_id)', | |
23 | + ]); | |
24 | + | |
25 | + // creates index for column `object_id` | |
26 | + $this->createIndex( | |
27 | + 'idx-object_to_object_category-object_id', | |
28 | + 'object_to_object_category', | |
29 | + 'object_id' | |
30 | + ); | |
31 | + | |
32 | + // add foreign key for table `object` | |
33 | + $this->addForeignKey( | |
34 | + 'fk-object_to_object_category-object_id', | |
35 | + 'object_to_object_category', | |
36 | + 'object_id', | |
37 | + 'object', | |
38 | + 'id', | |
39 | + 'CASCADE' | |
40 | + ); | |
41 | + | |
42 | + // creates index for column `object_category_id` | |
43 | + $this->createIndex( | |
44 | + 'idx-object_to_object_category-object_category_id', | |
45 | + 'object_to_object_category', | |
46 | + 'object_category_id' | |
47 | + ); | |
48 | + | |
49 | + // add foreign key for table `object_category` | |
50 | + $this->addForeignKey( | |
51 | + 'fk-object_to_object_category-object_category_id', | |
52 | + 'object_to_object_category', | |
53 | + 'object_category_id', | |
54 | + 'object_category', | |
55 | + 'id', | |
56 | + 'CASCADE' | |
57 | + ); | |
58 | + } | |
59 | + | |
60 | + /** | |
61 | + * @inheritdoc | |
62 | + */ | |
63 | + public function down() | |
64 | + { | |
65 | + // drops foreign key for table `object` | |
66 | + $this->dropForeignKey( | |
67 | + 'fk-object_to_object_category-object_id', | |
68 | + 'object_to_object_category' | |
69 | + ); | |
70 | + | |
71 | + // drops index for column `object_id` | |
72 | + $this->dropIndex( | |
73 | + 'idx-object_to_object_category-object_id', | |
74 | + 'object_to_object_category' | |
75 | + ); | |
76 | + | |
77 | + // drops foreign key for table `object_category` | |
78 | + $this->dropForeignKey( | |
79 | + 'fk-object_to_object_category-object_category_id', | |
80 | + 'object_to_object_category' | |
81 | + ); | |
82 | + | |
83 | + // drops index for column `object_category_id` | |
84 | + $this->dropIndex( | |
85 | + 'idx-object_to_object_category-object_category_id', | |
86 | + 'object_to_object_category' | |
87 | + ); | |
88 | + | |
89 | + $this->dropTable('object_to_object_category'); | |
90 | + } | |
91 | +} | ... | ... |
console/migrations/m180123_234322_create_object_lang_table.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles the creation of table `object_lang`. | |
7 | + * Has foreign keys to the tables: | |
8 | + * | |
9 | + * - `object` | |
10 | + * - `language` | |
11 | + * - `alias` | |
12 | + */ | |
13 | +class m180123_234322_create_object_lang_table extends Migration | |
14 | +{ | |
15 | + /** | |
16 | + * @inheritdoc | |
17 | + */ | |
18 | + public function up() | |
19 | + { | |
20 | + $this->createTable('object_lang', [ | |
21 | + 'object_id' => $this->integer()->notNull(), | |
22 | + 'language_id' => $this->integer()->notNull(), | |
23 | + 'alias_id' => $this->integer()->notNull()->unique(), | |
24 | + 'upper_text' => $this->text(), | |
25 | + 'about_object_text' => $this->text(), | |
26 | + 'object_name' => $this->string(50), | |
27 | + 'meta_title' => $this->string(300), | |
28 | + 'meta_description' => $this->string(300), | |
29 | + 'h1' => $this->string(50), | |
30 | + ]); | |
31 | + | |
32 | + // creates index for column `object_id` | |
33 | + $this->createIndex( | |
34 | + 'idx-object_lang-object_id', | |
35 | + 'object_lang', | |
36 | + 'object_id' | |
37 | + ); | |
38 | + | |
39 | + // add foreign key for table `object` | |
40 | + $this->addForeignKey( | |
41 | + 'fk-object_lang-object_id', | |
42 | + 'object_lang', | |
43 | + 'object_id', | |
44 | + 'object', | |
45 | + 'id', | |
46 | + 'CASCADE' | |
47 | + ); | |
48 | + | |
49 | + // creates index for column `language_id` | |
50 | + $this->createIndex( | |
51 | + 'idx-object_lang-language_id', | |
52 | + 'object_lang', | |
53 | + 'language_id' | |
54 | + ); | |
55 | + | |
56 | + // add foreign key for table `language` | |
57 | + $this->addForeignKey( | |
58 | + 'fk-object_lang-language_id', | |
59 | + 'object_lang', | |
60 | + 'language_id', | |
61 | + 'language', | |
62 | + 'id', | |
63 | + 'CASCADE' | |
64 | + ); | |
65 | + | |
66 | + // creates index for column `alias_id` | |
67 | + $this->createIndex( | |
68 | + 'idx-object_lang-alias_id', | |
69 | + 'object_lang', | |
70 | + 'alias_id' | |
71 | + ); | |
72 | + | |
73 | + // add foreign key for table `alias` | |
74 | + $this->addForeignKey( | |
75 | + 'fk-object_lang-alias_id', | |
76 | + 'object_lang', | |
77 | + 'alias_id', | |
78 | + 'alias', | |
79 | + 'id', | |
80 | + 'CASCADE' | |
81 | + ); | |
82 | + | |
83 | + // add double primary key | |
84 | + $this->addPrimaryKey( | |
85 | + "pk-object_lang-object_id-language_id", | |
86 | + "object_lang", | |
87 | + [ | |
88 | + "object_id", | |
89 | + "language_id", | |
90 | + ] | |
91 | + ); | |
92 | + } | |
93 | + | |
94 | + /** | |
95 | + * @inheritdoc | |
96 | + */ | |
97 | + public function down() | |
98 | + { | |
99 | + // drop double primary key | |
100 | + $this->dropPrimaryKey( | |
101 | + "pk-object_lang-object_id-language_id", | |
102 | + "object_lang" | |
103 | + ); | |
104 | + | |
105 | + // drops foreign key for table `object` | |
106 | + $this->dropForeignKey( | |
107 | + 'fk-object_lang-object_id', | |
108 | + 'object_lang' | |
109 | + ); | |
110 | + | |
111 | + // drops index for column `object_id` | |
112 | + $this->dropIndex( | |
113 | + 'idx-object_lang-object_id', | |
114 | + 'object_lang' | |
115 | + ); | |
116 | + | |
117 | + // drops foreign key for table `language` | |
118 | + $this->dropForeignKey( | |
119 | + 'fk-object_lang-language_id', | |
120 | + 'object_lang' | |
121 | + ); | |
122 | + | |
123 | + // drops index for column `language_id` | |
124 | + $this->dropIndex( | |
125 | + 'idx-object_lang-language_id', | |
126 | + 'object_lang' | |
127 | + ); | |
128 | + | |
129 | + // drops foreign key for table `alias` | |
130 | + $this->dropForeignKey( | |
131 | + 'fk-object_lang-alias_id', | |
132 | + 'object_lang' | |
133 | + ); | |
134 | + | |
135 | + // drops index for column `alias_id` | |
136 | + $this->dropIndex( | |
137 | + 'idx-object_lang-alias_id', | |
138 | + 'object_lang' | |
139 | + ); | |
140 | + | |
141 | + $this->dropTable('object_lang'); | |
142 | + } | |
143 | +} | ... | ... |
console/migrations/m180124_000452_add_image_mini_id_column_to_object_table.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles adding image_mini_id to table `object`. | |
7 | + * Has foreign keys to the tables: | |
8 | + * | |
9 | + * - `ImageManager` | |
10 | + */ | |
11 | +class m180124_000452_add_image_mini_id_column_to_object_table extends Migration | |
12 | +{ | |
13 | + /** | |
14 | + * @inheritdoc | |
15 | + */ | |
16 | + public function up() | |
17 | + { | |
18 | + $this->addColumn('object', 'image_mini_id', $this->integer()->notNull()); | |
19 | + | |
20 | + // creates index for column `image_mini_id` | |
21 | + $this->createIndex( | |
22 | + 'idx-object-image_mini_id', | |
23 | + 'object', | |
24 | + 'image_mini_id' | |
25 | + ); | |
26 | + | |
27 | + // add foreign key for table `ImageManager` | |
28 | + $this->addForeignKey( | |
29 | + 'fk-object-image_mini_id', | |
30 | + 'object', | |
31 | + 'image_mini_id', | |
32 | + 'ImageManager', | |
33 | + 'id', | |
34 | + 'CASCADE' | |
35 | + ); | |
36 | + } | |
37 | + | |
38 | + /** | |
39 | + * @inheritdoc | |
40 | + */ | |
41 | + public function down() | |
42 | + { | |
43 | + // drops foreign key for table `ImageManager` | |
44 | + $this->dropForeignKey( | |
45 | + 'fk-object-image_mini_id', | |
46 | + 'object' | |
47 | + ); | |
48 | + | |
49 | + // drops index for column `image_mini_id` | |
50 | + $this->dropIndex( | |
51 | + 'idx-object-image_mini_id', | |
52 | + 'object' | |
53 | + ); | |
54 | + | |
55 | + $this->dropColumn('object', 'image_mini_id'); | |
56 | + } | |
57 | +} | ... | ... |
frontend/controllers/SiteController.php
... | ... | @@ -77,13 +77,36 @@ |
77 | 77 | { |
78 | 78 | return $this->render('about'); |
79 | 79 | } |
80 | - | |
81 | - public function actionIndividual(){return $this->render('individual');} // частное лицо | |
82 | - public function actionLegal(){return $this->render('legal');} // юридическое | |
83 | - public function actionObjects(){return $this->render('objects');} // наши объекты | |
84 | - public function actionGreen(){return $this->render('green');} // зелёный тариф | |
85 | - public function actionMediaAbout(){return $this->render('media-about');} // СМИ о нас | |
86 | - public function actionBlog(){return $this->render('blog');} // блог | |
80 | + | |
81 | + public function actionIndividual() | |
82 | + { | |
83 | + return $this->render('individual'); | |
84 | + } // частное лицо | |
85 | + | |
86 | + public function actionLegal() | |
87 | + { | |
88 | + return $this->render('legal'); | |
89 | + } // юридическое | |
90 | + | |
91 | + public function actionObjects() | |
92 | + { | |
93 | + return $this->render('objects'); | |
94 | + } // наши объекты | |
95 | + | |
96 | + public function actionGreen() | |
97 | + { | |
98 | + return $this->render('green'); | |
99 | + } // зелёный тариф | |
100 | + | |
101 | + public function actionMediaAbout() | |
102 | + { | |
103 | + return $this->render('media-about'); | |
104 | + } // СМИ о нас | |
105 | + | |
106 | + public function actionBlog() | |
107 | + { | |
108 | + return $this->render('blog'); | |
109 | + } // блог | |
87 | 110 | |
88 | 111 | /** |
89 | 112 | * Action to view robots.txt file dinamycli | ... | ... |
frontend/views/site/objects.php
... | ... | @@ -21,9 +21,9 @@ $this->params[ 'breadcrumbs' ][] = $this->title; |
21 | 21 | <div id="objects-wr"> |
22 | 22 | <div id="content"> |
23 | 23 | <div class="container"> |
24 | - | |
24 | + | |
25 | 25 | <section> |
26 | - | |
26 | + | |
27 | 27 | <div class="row"> |
28 | 28 | <div class="col-md-12"> |
29 | 29 | <!--<div class="heading"> |
... | ... | @@ -32,38 +32,50 @@ $this->params[ 'breadcrumbs' ][] = $this->title; |
32 | 32 | <p class="lead">Туристическое агентство “WhereAreYou” осуществляет нестандартные поездки с 2003 года. Мы занимаемся не просто путешествием, а для каждого лично составляем полноценный план поездки: что лучше посетить, длительность пребывания исходя из ваших средств. Все что требуется от вас — назвать город, страну и бюджет.</p> |
33 | 33 | </div> |
34 | 34 | </div> |
35 | - | |
35 | + | |
36 | 36 | <div class="row portfolio"> |
37 | - <?php | |
38 | - $objects = ['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg',]; | |
39 | - foreach($objects as $object){ | |
40 | - $link = 'img/objects/'.$object; | |
41 | - if(file_exists($link)){?> | |
42 | - | |
37 | + <?php | |
38 | + $objects = [ | |
39 | + '1.jpg', | |
40 | + '2.jpg', | |
41 | + '3.jpg', | |
42 | + '4.jpg', | |
43 | + '5.jpg', | |
44 | + '6.jpg', | |
45 | + '7.jpg', | |
46 | + '8.jpg', | |
47 | + ]; | |
48 | + foreach ($objects as $object) { | |
49 | + $link = 'img/objects/' . $object; | |
50 | + if (file_exists($link)) { | |
51 | + ?> | |
52 | + | |
43 | 53 | <div class="col-sm-6"> |
44 | 54 | <div class="box-image"> |
45 | 55 | <div class="image"> |
46 | - <img src="/<?=$link?>" alt="" class="img-responsive"> | |
56 | + <img src="/<?= $link ?>" alt="" class="img-responsive"> | |
47 | 57 | </div> |
48 | - <!--<div class="bg"></div>--> | |
49 | - <!--<div class="name"> | |
58 | + <div class="bg"></div> | |
59 | + <div class="name"> | |
50 | 60 | <h3><a href="#">Фото в портфолио</a></h3> |
51 | - </div>--> | |
52 | - <!--<div class="text"> | |
61 | + </div> | |
62 | + <div class="text"> | |
53 | 63 | <p class="buttons"> |
54 | 64 | <a href="#" class="btn btn-template-transparent-primary">Посмотреть</a> |
55 | 65 | </p> |
56 | - </div>--> | |
66 | + </div> | |
57 | 67 | </div> |
58 | 68 | </div> |
59 | - <?} | |
60 | - } | |
61 | - ?> | |
69 | + | |
70 | + <?php | |
71 | + } | |
72 | + } | |
73 | + ?> | |
62 | 74 | </div> |
63 | - | |
64 | - | |
75 | + | |
76 | + | |
65 | 77 | </section> |
66 | - | |
78 | + | |
67 | 79 | </div> |
68 | 80 | </div> |
69 | 81 | </div> |
70 | 82 | \ No newline at end of file | ... | ... |