Commit 6fc26f8f9b69c5c1a7ffc4887cc2ec7f359c58da
1 parent
298bc0f4
- slider
- events - gallery
Showing
30 changed files
with
1600 additions
and
39 deletions
Show diff stats
| 1 | +<?php | ||
| 2 | + /** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: stes | ||
| 5 | + * Date: 04.04.18 | ||
| 6 | + * Time: 12:19 | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | + namespace backend\controllers; | ||
| 10 | + | ||
| 11 | + use artbox\core\admin\actions\Create; | ||
| 12 | + use artbox\core\admin\actions\Delete; | ||
| 13 | + use artbox\core\admin\actions\Index; | ||
| 14 | + use artbox\core\admin\actions\Update; | ||
| 15 | + use artbox\core\admin\actions\View; | ||
| 16 | + use artbox\core\admin\interfaces\ControllerInterface; | ||
| 17 | + use artbox\core\admin\widgets\Form; | ||
| 18 | + use common\models\event\Event; | ||
| 19 | + use yii\filters\AccessControl; | ||
| 20 | + use yii\filters\VerbFilter; | ||
| 21 | + use yii\web\Controller; | ||
| 22 | + use yii\web\NotFoundHttpException; | ||
| 23 | + | ||
| 24 | + class EventController extends Controller implements ControllerInterface | ||
| 25 | + { | ||
| 26 | + public function behaviors() | ||
| 27 | + { | ||
| 28 | + return [ | ||
| 29 | + 'verbs' => [ | ||
| 30 | + 'class' => VerbFilter::className(), | ||
| 31 | + 'actions' => [ | ||
| 32 | + 'delete' => [ 'POST' ], | ||
| 33 | + ], | ||
| 34 | + ], | ||
| 35 | + 'access' => [ | ||
| 36 | + 'class' => AccessControl::className(), | ||
| 37 | + 'rules' => [ | ||
| 38 | + [ | ||
| 39 | + 'allow' => true, | ||
| 40 | + 'roles' => [ '@' ], | ||
| 41 | + ], | ||
| 42 | + ], | ||
| 43 | + ], | ||
| 44 | + ]; | ||
| 45 | + } | ||
| 46 | + public function actions() | ||
| 47 | + { | ||
| 48 | + return [ | ||
| 49 | + 'index' => [ | ||
| 50 | + 'class' => Index::className(), | ||
| 51 | + 'columns' => [ | ||
| 52 | + 'title' => [ | ||
| 53 | + 'type' => Index::ACTION_COL, | ||
| 54 | + ], | ||
| 55 | + 'tags' => [ | ||
| 56 | + 'type' => Index::RELATION_COL, | ||
| 57 | + 'columnConfig' => [ | ||
| 58 | + 'relationField' => 'title', | ||
| 59 | + ], | ||
| 60 | + ], | ||
| 61 | + 'created_at' => [ | ||
| 62 | + 'type' => Index::DATETIME_COL, | ||
| 63 | + ], | ||
| 64 | + 'sort' => [ | ||
| 65 | + 'type' => Index::POSITION_COL, | ||
| 66 | + ], | ||
| 67 | + 'status' => [ | ||
| 68 | + 'type' => Index::STATUS_COL, | ||
| 69 | + ], | ||
| 70 | + ], | ||
| 71 | + 'model' => Event::className(), | ||
| 72 | + 'hasLanguage' => true, | ||
| 73 | + 'enableMassDelete' => true, | ||
| 74 | + 'modelPrimaryKey' => 'id', | ||
| 75 | + ], | ||
| 76 | + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()), | ||
| 77 | + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()), | ||
| 78 | + 'view' => [ | ||
| 79 | + 'class' => View::className(), | ||
| 80 | + 'model' => Event::className(), | ||
| 81 | + 'hasAlias' => true, | ||
| 82 | + 'languageFields' => [ | ||
| 83 | + [ | ||
| 84 | + 'name' => 'title', | ||
| 85 | + 'type' => Form::STRING, | ||
| 86 | + ], | ||
| 87 | + [ | ||
| 88 | + 'name' => 'body', | ||
| 89 | + 'type' => Form::WYSIWYG, | ||
| 90 | + ], | ||
| 91 | + [ | ||
| 92 | + 'name' => 'body_preview', | ||
| 93 | + 'type' => Form::TEXTAREA, | ||
| 94 | + ], | ||
| 95 | + ], | ||
| 96 | + 'fields' => [ | ||
| 97 | + [ | ||
| 98 | + 'name' => 'image_id', | ||
| 99 | + 'type' => Form::IMAGE, | ||
| 100 | + ], | ||
| 101 | + [ | ||
| 102 | + 'name' => 'tagIds', | ||
| 103 | + 'type' => Form::RELATION, | ||
| 104 | + 'relationAttribute' => 'label', | ||
| 105 | + 'relationName' => 'tags', | ||
| 106 | + 'multiple' => true, | ||
| 107 | + ], | ||
| 108 | + ], | ||
| 109 | + ], | ||
| 110 | + 'delete' => [ | ||
| 111 | + 'class' => Delete::className(), | ||
| 112 | + ], | ||
| 113 | + ]; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + public function findModel($id) | ||
| 117 | + { | ||
| 118 | + $model = Event::find() | ||
| 119 | + ->with('languages') | ||
| 120 | + ->where([ 'id' => $id ]) | ||
| 121 | + ->one(); | ||
| 122 | + if ($model !== null) { | ||
| 123 | + return $model; | ||
| 124 | + } else { | ||
| 125 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public function newModel() | ||
| 130 | + { | ||
| 131 | + return new Event(); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + public function deleteModel($id) | ||
| 135 | + { | ||
| 136 | + $page = Event::find() | ||
| 137 | + ->with('languages.alias') | ||
| 138 | + ->where( | ||
| 139 | + [ | ||
| 140 | + 'id' => $id, | ||
| 141 | + ] | ||
| 142 | + ) | ||
| 143 | + ->one(); | ||
| 144 | + $langs = call_user_func( | ||
| 145 | + [ | ||
| 146 | + $page, | ||
| 147 | + 'getVariationModels', | ||
| 148 | + ] | ||
| 149 | + ); | ||
| 150 | + foreach ($langs as $lang) { | ||
| 151 | + if ($lang->alias !== null) { | ||
| 152 | + $lang->alias->delete(); | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + return $page->delete(); | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + protected static function fieldsConfig() | ||
| 160 | + { | ||
| 161 | + return [ | ||
| 162 | + 'model' => Event::className(), | ||
| 163 | + 'hasAlias' => true, | ||
| 164 | + 'languageFields' => [ | ||
| 165 | + [ | ||
| 166 | + 'name' => 'title', | ||
| 167 | + 'type' => Form::STRING, | ||
| 168 | + ], | ||
| 169 | + [ | ||
| 170 | + 'name' => 'body', | ||
| 171 | + 'type' => Form::WYSIWYG, | ||
| 172 | + ], | ||
| 173 | + [ | ||
| 174 | + 'name' => 'body_preview', | ||
| 175 | + 'type' => Form::TEXTAREA, | ||
| 176 | + ], | ||
| 177 | + ], | ||
| 178 | + 'fields' => [ | ||
| 179 | + | ||
| 180 | + [ | ||
| 181 | + 'name' => 'image_id', | ||
| 182 | + 'type' => Form::IMAGE, | ||
| 183 | + ], | ||
| 184 | + [ | ||
| 185 | + 'name' => 'tagIds', | ||
| 186 | + 'type' => Form::RELATION, | ||
| 187 | + 'relationAttribute' => 'title', | ||
| 188 | + 'relationName' => 'tags', | ||
| 189 | + 'multiple' => true, | ||
| 190 | + ], | ||
| 191 | + [ | ||
| 192 | + 'name' => 'status', | ||
| 193 | + 'type' => Form::BOOL, | ||
| 194 | + ], | ||
| 195 | + [ | ||
| 196 | + 'name' => 'sort', | ||
| 197 | + 'type' => Form::NUMBER, | ||
| 198 | + ], | ||
| 199 | + ], | ||
| 200 | + ]; | ||
| 201 | + } | ||
| 202 | + } | ||
| 0 | \ No newline at end of file | 203 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | + /** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: stes | ||
| 5 | + * Date: 04.04.18 | ||
| 6 | + * Time: 12:42 | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | + namespace backend\controllers; | ||
| 10 | + | ||
| 11 | + use artbox\core\admin\actions\Create; | ||
| 12 | + use artbox\core\admin\actions\Delete; | ||
| 13 | + use artbox\core\admin\actions\Index; | ||
| 14 | + use artbox\core\admin\actions\Update; | ||
| 15 | + use artbox\core\admin\actions\View; | ||
| 16 | + use artbox\core\admin\interfaces\ControllerInterface; | ||
| 17 | + use artbox\core\admin\widgets\Form; | ||
| 18 | + use common\models\event\Tag; | ||
| 19 | + use yii\filters\AccessControl; | ||
| 20 | + use yii\filters\VerbFilter; | ||
| 21 | + use yii\web\Controller; | ||
| 22 | + use yii\web\NotFoundHttpException; | ||
| 23 | + | ||
| 24 | + class EventTagController extends Controller implements ControllerInterface | ||
| 25 | + { | ||
| 26 | + public function behaviors() | ||
| 27 | + { | ||
| 28 | + return [ | ||
| 29 | + 'verbs' => [ | ||
| 30 | + 'class' => VerbFilter::className(), | ||
| 31 | + 'actions' => [ | ||
| 32 | + 'delete' => [ 'POST' ], | ||
| 33 | + ], | ||
| 34 | + ], | ||
| 35 | + 'access' => [ | ||
| 36 | + 'class' => AccessControl::className(), | ||
| 37 | + 'rules' => [ | ||
| 38 | + [ | ||
| 39 | + 'allow' => true, | ||
| 40 | + 'roles' => [ '@' ], | ||
| 41 | + ], | ||
| 42 | + ], | ||
| 43 | + ], | ||
| 44 | + ]; | ||
| 45 | + } | ||
| 46 | + public function actions() | ||
| 47 | + { | ||
| 48 | + return [ | ||
| 49 | + 'index' => [ | ||
| 50 | + 'class' => Index::className(), | ||
| 51 | + 'columns' => [ | ||
| 52 | + 'title' => [ | ||
| 53 | + 'type' => Index::ACTION_COL, | ||
| 54 | + ], | ||
| 55 | + 'sort' => [ | ||
| 56 | + 'type' => Index::POSITION_COL, | ||
| 57 | + ], | ||
| 58 | + ], | ||
| 59 | + 'model' => Tag::className(), | ||
| 60 | + 'hasLanguage' => true, | ||
| 61 | + 'enableMassDelete' => true, | ||
| 62 | + 'modelPrimaryKey' => 'id', | ||
| 63 | + ], | ||
| 64 | + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()), | ||
| 65 | + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()), | ||
| 66 | + 'view' => [ | ||
| 67 | + 'class' => View::className(), | ||
| 68 | + 'model' => Tag::className(), | ||
| 69 | + 'hasAlias' => true, | ||
| 70 | + 'hasGallery' => false, | ||
| 71 | + 'languageFields' => [ | ||
| 72 | + [ | ||
| 73 | + 'name' => 'title', | ||
| 74 | + 'type' => Form::STRING, | ||
| 75 | + ] | ||
| 76 | + ], | ||
| 77 | + 'fields' => [ | ||
| 78 | + ], | ||
| 79 | + ], | ||
| 80 | + 'delete' => [ | ||
| 81 | + 'class' => Delete::className(), | ||
| 82 | + ], | ||
| 83 | + ]; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public function findModel($id) | ||
| 87 | + { | ||
| 88 | + $model = Tag::find() | ||
| 89 | + ->with('languages') | ||
| 90 | + ->where([ 'id' => $id ]) | ||
| 91 | + ->one(); | ||
| 92 | + if ($model !== null) { | ||
| 93 | + return $model; | ||
| 94 | + } else { | ||
| 95 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public function newModel() | ||
| 100 | + { | ||
| 101 | + return new Tag(); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public function deleteModel($id) | ||
| 105 | + { | ||
| 106 | + $category = Tag::find() | ||
| 107 | + ->with('languages.alias') | ||
| 108 | + ->where( | ||
| 109 | + [ | ||
| 110 | + 'id' => $id, | ||
| 111 | + ] | ||
| 112 | + ) | ||
| 113 | + ->one(); | ||
| 114 | + $langs = call_user_func( | ||
| 115 | + [ | ||
| 116 | + $category, | ||
| 117 | + 'getVariationModels', | ||
| 118 | + ] | ||
| 119 | + ); | ||
| 120 | + foreach ($langs as $lang) { | ||
| 121 | + if ($lang->alias !== null) { | ||
| 122 | + $lang->alias->delete(); | ||
| 123 | + } | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + return $category->delete(); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + protected static function fieldsConfig() | ||
| 130 | + { | ||
| 131 | + return [ | ||
| 132 | + 'model' => Tag::className(), | ||
| 133 | + 'hasAlias' => true, | ||
| 134 | + 'hasGallery' => false, | ||
| 135 | + 'languageFields' => [ | ||
| 136 | + [ | ||
| 137 | + 'name' => 'title', | ||
| 138 | + 'type' => Form::STRING, | ||
| 139 | + ] | ||
| 140 | + ], | ||
| 141 | + 'fields' => [ | ||
| 142 | + [ | ||
| 143 | + 'name' => 'sort', | ||
| 144 | + 'type' => Form::NUMBER, | ||
| 145 | + ], | ||
| 146 | + ], | ||
| 147 | + ]; | ||
| 148 | + } | ||
| 149 | + } | ||
| 0 | \ No newline at end of file | 150 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | + /** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: stes | ||
| 5 | + * Date: 07.05.18 | ||
| 6 | + * Time: 15:14 | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | + namespace backend\controllers; | ||
| 10 | + | ||
| 11 | + use artbox\core\admin\actions\Create; | ||
| 12 | + use artbox\core\admin\actions\Delete; | ||
| 13 | + use artbox\core\admin\actions\Index; | ||
| 14 | + use artbox\core\admin\actions\Update; | ||
| 15 | + use artbox\core\admin\actions\View; | ||
| 16 | + use artbox\core\admin\interfaces\ControllerInterface; | ||
| 17 | + use artbox\core\admin\widgets\Form; | ||
| 18 | + use common\models\Gallery; | ||
| 19 | + use yii\filters\AccessControl; | ||
| 20 | + use yii\filters\VerbFilter; | ||
| 21 | + use yii\web\Controller; | ||
| 22 | + use yii\web\NotFoundHttpException; | ||
| 23 | + | ||
| 24 | + class GalleryController extends Controller implements ControllerInterface | ||
| 25 | + { | ||
| 26 | + public function behaviors() | ||
| 27 | + { | ||
| 28 | + return [ | ||
| 29 | + 'verbs' => [ | ||
| 30 | + 'class' => VerbFilter::className(), | ||
| 31 | + 'actions' => [ | ||
| 32 | + 'delete' => [ 'POST' ], | ||
| 33 | + ], | ||
| 34 | + ], | ||
| 35 | + 'access' => [ | ||
| 36 | + 'class' => AccessControl::className(), | ||
| 37 | + 'rules' => [ | ||
| 38 | + [ | ||
| 39 | + 'allow' => true, | ||
| 40 | + 'roles' => [ '@' ], | ||
| 41 | + ], | ||
| 42 | + ], | ||
| 43 | + ], | ||
| 44 | + ]; | ||
| 45 | + } | ||
| 46 | + public function actions() | ||
| 47 | + { | ||
| 48 | + return [ | ||
| 49 | + 'index' => [ | ||
| 50 | + 'class' => Index::className(), | ||
| 51 | + 'columns' => [ | ||
| 52 | + 'title' => [ | ||
| 53 | + 'type' => Index::ACTION_COL | ||
| 54 | + ], | ||
| 55 | + 'sort' => [ | ||
| 56 | + 'type' => Index::POSITION_COL, | ||
| 57 | + ], | ||
| 58 | + 'status' => [ | ||
| 59 | + 'type' => Index::STATUS_COL | ||
| 60 | + ] | ||
| 61 | + ], | ||
| 62 | + 'model' => Gallery::className(), | ||
| 63 | + 'hasLanguage' => true, | ||
| 64 | + 'enableMassDelete' => true, | ||
| 65 | + 'modelPrimaryKey' => 'id', | ||
| 66 | + ], | ||
| 67 | + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()), | ||
| 68 | + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()), | ||
| 69 | + 'view' => [ | ||
| 70 | + 'class' => View::className(), | ||
| 71 | + 'model' => Gallery::className(), | ||
| 72 | + 'hasAlias' => false, | ||
| 73 | + 'hasGallery' => false, | ||
| 74 | + 'languageFields' => [ | ||
| 75 | + [ | ||
| 76 | + 'name' => 'title', | ||
| 77 | + 'type' => Form::STRING, | ||
| 78 | + ] | ||
| 79 | + ], | ||
| 80 | + 'fields' => [ | ||
| 81 | + [ | ||
| 82 | + 'name' => 'image_id', | ||
| 83 | + 'type' => Form::IMAGE, | ||
| 84 | + ], | ||
| 85 | + ], | ||
| 86 | + ], | ||
| 87 | + 'delete' => [ | ||
| 88 | + 'class' => Delete::className(), | ||
| 89 | + ], | ||
| 90 | + ]; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public function findModel($id) | ||
| 94 | + { | ||
| 95 | + $model = Gallery::find() | ||
| 96 | + ->with('languages') | ||
| 97 | + ->where([ 'id' => $id ]) | ||
| 98 | + ->one(); | ||
| 99 | + if ($model !== null) { | ||
| 100 | + return $model; | ||
| 101 | + } else { | ||
| 102 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + public function newModel() | ||
| 107 | + { | ||
| 108 | + return new Gallery(); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + public function deleteModel($id) | ||
| 112 | + { | ||
| 113 | + $page = Gallery::find() | ||
| 114 | + ->with('languages') | ||
| 115 | + ->where( | ||
| 116 | + [ | ||
| 117 | + 'id' => $id, | ||
| 118 | + ] | ||
| 119 | + ) | ||
| 120 | + ->one(); | ||
| 121 | + | ||
| 122 | + return $page->delete(); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + protected static function fieldsConfig() | ||
| 126 | + { | ||
| 127 | + return [ | ||
| 128 | + 'model' => Gallery::className(), | ||
| 129 | + 'hasAlias' => false, | ||
| 130 | + 'hasGallery' => false, | ||
| 131 | + 'languageFields' => [ | ||
| 132 | + [ | ||
| 133 | + 'name' => 'title', | ||
| 134 | + 'type' => Form::STRING, | ||
| 135 | + ], | ||
| 136 | + ], | ||
| 137 | + 'fields' => [ | ||
| 138 | + [ | ||
| 139 | + 'name' => 'image_id', | ||
| 140 | + 'type' => Form::IMAGE, | ||
| 141 | + ], | ||
| 142 | + [ | ||
| 143 | + 'name' => 'status', | ||
| 144 | + 'type' => Form::BOOL, | ||
| 145 | + ], | ||
| 146 | + [ | ||
| 147 | + 'name' => 'sort', | ||
| 148 | + 'type' => Form::NUMBER, | ||
| 149 | + ], | ||
| 150 | + ], | ||
| 151 | + ]; | ||
| 152 | + } | ||
| 153 | + } | ||
| 0 | \ No newline at end of file | 154 | \ No newline at end of file |
backend/controllers/SlideController.php
| @@ -78,7 +78,12 @@ | @@ -78,7 +78,12 @@ | ||
| 78 | [ | 78 | [ |
| 79 | 'name' => 'title', | 79 | 'name' => 'title', |
| 80 | 'type' => Form::STRING, | 80 | 'type' => Form::STRING, |
| 81 | - ],[ | 81 | + ], |
| 82 | + [ | ||
| 83 | + 'name' => 'description', | ||
| 84 | + 'type' => Form::TEXTAREA, | ||
| 85 | + ], | ||
| 86 | + [ | ||
| 82 | 'name' => 'link', | 87 | 'name' => 'link', |
| 83 | 'type' => Form::STRING, | 88 | 'type' => Form::STRING, |
| 84 | ], | 89 | ], |
| @@ -96,6 +101,10 @@ | @@ -96,6 +101,10 @@ | ||
| 96 | [ | 101 | [ |
| 97 | 'name' => 'sort', | 102 | 'name' => 'sort', |
| 98 | 'type' => Form::NUMBER, | 103 | 'type' => Form::NUMBER, |
| 104 | + ], | ||
| 105 | + [ | ||
| 106 | + 'name' => 'background_id', | ||
| 107 | + 'type' => Form::IMAGE, | ||
| 99 | ] | 108 | ] |
| 100 | ], | 109 | ], |
| 101 | ], | 110 | ], |
| @@ -163,6 +172,10 @@ | @@ -163,6 +172,10 @@ | ||
| 163 | 'type' => Form::STRING, | 172 | 'type' => Form::STRING, |
| 164 | ], | 173 | ], |
| 165 | [ | 174 | [ |
| 175 | + 'name' => 'description', | ||
| 176 | + 'type' => Form::TEXTAREA, | ||
| 177 | + ], | ||
| 178 | + [ | ||
| 166 | 'name' => 'link', | 179 | 'name' => 'link', |
| 167 | 'type' => Form::STRING, | 180 | 'type' => Form::STRING, |
| 168 | ], | 181 | ], |
| @@ -170,6 +183,10 @@ | @@ -170,6 +183,10 @@ | ||
| 170 | ], | 183 | ], |
| 171 | 'fields' => [ | 184 | 'fields' => [ |
| 172 | [ | 185 | [ |
| 186 | + 'name' => 'background_id', | ||
| 187 | + 'type' => Form::IMAGE, | ||
| 188 | + ], | ||
| 189 | + [ | ||
| 173 | 'name' => 'status', | 190 | 'name' => 'status', |
| 174 | 'type' => Form::BOOL, | 191 | 'type' => Form::BOOL, |
| 175 | ], | 192 | ], |
backend/views/layouts/menu_items.php
| 1 | +<?php | ||
| 2 | + /** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: stes | ||
| 5 | + * Date: 07.05.18 | ||
| 6 | + * Time: 14:57 | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | + namespace common\models; | ||
| 10 | + | ||
| 11 | + use artbox\core\models\Image; | ||
| 12 | + use artbox\core\models\Language; | ||
| 13 | + use yii\db\ActiveQuery; | ||
| 14 | + use yii\db\ActiveRecord; | ||
| 15 | + use yii2tech\ar\position\PositionBehavior; | ||
| 16 | + use yii2tech\ar\variation\VariationBehavior; | ||
| 17 | + | ||
| 18 | + class Gallery extends ActiveRecord | ||
| 19 | + { | ||
| 20 | + public function rules() | ||
| 21 | + { | ||
| 22 | + return [ | ||
| 23 | + [ | ||
| 24 | + [ 'sort' ], | ||
| 25 | + 'integer', | ||
| 26 | + ], | ||
| 27 | + [ | ||
| 28 | + [ 'status' ], | ||
| 29 | + 'boolean', | ||
| 30 | + ], | ||
| 31 | + [ | ||
| 32 | + [ 'image_id' ], | ||
| 33 | + 'required' | ||
| 34 | + ] | ||
| 35 | + ]; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public function behaviors() | ||
| 39 | + { | ||
| 40 | + return [ | ||
| 41 | + 'translations' => [ | ||
| 42 | + 'class' => VariationBehavior::className(), | ||
| 43 | + 'variationsRelation' => 'languages', | ||
| 44 | + 'defaultVariationRelation' => 'language', | ||
| 45 | + 'variationOptionReferenceAttribute' => 'language_id', | ||
| 46 | + 'optionModelClass' => Language::className(), | ||
| 47 | + 'defaultVariationOptionReference' => function () { | ||
| 48 | + return Language::getCurrent()->id; | ||
| 49 | + }, | ||
| 50 | + 'optionQueryFilter' => function (ActiveQuery $query) { | ||
| 51 | + $query->where( | ||
| 52 | + [ | ||
| 53 | + 'status' => true, | ||
| 54 | + ] | ||
| 55 | + ); | ||
| 56 | + }, | ||
| 57 | + ], | ||
| 58 | + 'positionBehavior' => [ | ||
| 59 | + 'class' => PositionBehavior::className(), | ||
| 60 | + 'positionAttribute' => 'sort', | ||
| 61 | + ], | ||
| 62 | + ]; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public static function tableName() | ||
| 66 | + { | ||
| 67 | + return 'gallery'; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * @return \yii\db\ActiveQuery | ||
| 72 | + */ | ||
| 73 | + public function getLanguages() | ||
| 74 | + { | ||
| 75 | + return $this->hasMany(GalleryLang::className(), [ 'gallery_id' => 'id' ]); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * @return \yii\db\ActiveQuery | ||
| 80 | + */ | ||
| 81 | + public function getLanguage() | ||
| 82 | + { | ||
| 83 | + return $this->hasDefaultVariationRelation(); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public function attributeLabels() | ||
| 87 | + { | ||
| 88 | + return [ | ||
| 89 | + 'title' => \Yii::t('core', 'Title'), | ||
| 90 | + 'status' => \Yii::t('core', 'Status'), | ||
| 91 | + 'sort' => \Yii::t('core', 'Sort'), | ||
| 92 | + 'image_id' => \Yii::t('core', 'Image'), | ||
| 93 | + ]; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + /** | ||
| 97 | + * @return \yii\db\ActiveQuery | ||
| 98 | + */ | ||
| 99 | + public function getImage() | ||
| 100 | + { | ||
| 101 | + return $this->hasOne(Image::className(), [ 'id' => 'image_id' ]); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + | ||
| 105 | + } | ||
| 0 | \ No newline at end of file | 106 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | + /** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: stes | ||
| 5 | + * Date: 07.05.18 | ||
| 6 | + * Time: 15:09 | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | + namespace common\models; | ||
| 10 | + | ||
| 11 | + use yii\db\ActiveRecord; | ||
| 12 | + | ||
| 13 | + class GalleryLang extends ActiveRecord | ||
| 14 | + { | ||
| 15 | + public static function tableName() | ||
| 16 | + { | ||
| 17 | + return 'gallery_lang'; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public function rules() | ||
| 21 | + { | ||
| 22 | + return [ | ||
| 23 | + [ | ||
| 24 | + [ | ||
| 25 | + 'title', | ||
| 26 | + ], | ||
| 27 | + 'string', | ||
| 28 | + ], | ||
| 29 | + ]; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public function attributeLabels() | ||
| 33 | + { | ||
| 34 | + return [ | ||
| 35 | + 'title' => \Yii::t('core', 'Title'), | ||
| 36 | + ]; | ||
| 37 | + } | ||
| 38 | + } | ||
| 0 | \ No newline at end of file | 39 | \ No newline at end of file |
common/models/blog/Article.php
| @@ -18,22 +18,22 @@ | @@ -18,22 +18,22 @@ | ||
| 18 | /** | 18 | /** |
| 19 | * This is the model class for table "blog_article". | 19 | * This is the model class for table "blog_article". |
| 20 | * | 20 | * |
| 21 | - * @property integer $id | ||
| 22 | - * @property Image $image | ||
| 23 | - * @property integer $created_at | ||
| 24 | - * @property integer $updated_at | ||
| 25 | - * @property integer $deleted_at | ||
| 26 | - * @property integer $sort | ||
| 27 | - * @property boolean $status | ||
| 28 | - * @property integer $author_id | ||
| 29 | - * @property integer $image_id | 21 | + * @property integer $id |
| 22 | + * @property Image $image | ||
| 23 | + * @property integer $created_at | ||
| 24 | + * @property integer $updated_at | ||
| 25 | + * @property integer $deleted_at | ||
| 26 | + * @property integer $sort | ||
| 27 | + * @property boolean $status | ||
| 28 | + * @property integer $author_id | ||
| 29 | + * @property integer $image_id | ||
| 30 | * @property ArticleLang[] $blogArticleLangs | 30 | * @property ArticleLang[] $blogArticleLangs |
| 31 | - * @property Language[] $languages | ||
| 32 | - * @property Article[] $relatedBlogArticles | ||
| 33 | - * @property Article[] $articles | ||
| 34 | - * @property Category[] $categories | ||
| 35 | - * @property Category $category | ||
| 36 | - * @property Tag[] $tags | 31 | + * @property Language[] $languages |
| 32 | + * @property \common\models\blog\Article[] $relatedBlogArticles | ||
| 33 | + * @property \common\models\blog\Article[] $articles | ||
| 34 | + * @property Category[] $categories | ||
| 35 | + * @property Category $category | ||
| 36 | + * @property Tag[] $tags | ||
| 37 | * * from VariationBehavior | 37 | * * from VariationBehavior |
| 38 | * @method ActiveQuery hasDefaultVariationRelation(); | 38 | * @method ActiveQuery hasDefaultVariationRelation(); |
| 39 | */ | 39 | */ |
common/models/blog/ArticleLang.php
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | * @property string $meta_description | 19 | * @property string $meta_description |
| 20 | * @property string $h1 | 20 | * @property string $h1 |
| 21 | * @property string $seo_text | 21 | * @property string $seo_text |
| 22 | - * @property Article $article | 22 | + * @property Article $article |
| 23 | * @property Language $language | 23 | * @property Language $language |
| 24 | * @property Alias $alias | 24 | * @property Alias $alias |
| 25 | */ | 25 | */ |
common/models/blog/Category.php
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | * @property integer $sort | 18 | * @property integer $sort |
| 19 | * @property integer $parent_id | 19 | * @property integer $parent_id |
| 20 | * @property boolean $status | 20 | * @property boolean $status |
| 21 | - * @property Article[] $articles | 21 | + * @property Article[] $articles |
| 22 | * @property CategoryLang[] $blogCategoryLangs | 22 | * @property CategoryLang[] $blogCategoryLangs |
| 23 | * @property Language[] $languages | 23 | * @property Language[] $languages |
| 24 | * @property Category $parent | 24 | * @property Category $parent |
common/models/blog/Tag.php
| @@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
| 14 | * This is the model class for table "blog_tag". | 14 | * This is the model class for table "blog_tag". |
| 15 | * | 15 | * |
| 16 | * @property integer $id | 16 | * @property integer $id |
| 17 | - * @property Article[] $articles | 17 | + * @property Article[] $articles |
| 18 | * @property TagLang[] $blogTagLangs | 18 | * @property TagLang[] $blogTagLangs |
| 19 | * @property Language[] $languages | 19 | * @property Language[] $languages |
| 20 | * * * from VariationBehavior | 20 | * * * from VariationBehavior |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace common\models\event; | ||
| 4 | + | ||
| 5 | + use artbox\core\models\Image; | ||
| 6 | + use artbox\core\models\traits\AliasableTrait; | ||
| 7 | + use artbox\webcomment\models\CommentModel; | ||
| 8 | + use yii\behaviors\TimestampBehavior; | ||
| 9 | + use yii\db\ActiveRecord; | ||
| 10 | + use artbox\core\models\Language; | ||
| 11 | + use yii\db\ActiveQuery; | ||
| 12 | + use yii\db\Query; | ||
| 13 | + use yii\helpers\Json; | ||
| 14 | + use yii2tech\ar\linkmany\LinkManyBehavior; | ||
| 15 | + use yii2tech\ar\position\PositionBehavior; | ||
| 16 | + use yii2tech\ar\variation\VariationBehavior; | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * This is the model class for table "blog_article". | ||
| 20 | + * | ||
| 21 | + * @property integer $id | ||
| 22 | + * @property Image $image | ||
| 23 | + * @property integer $created_at | ||
| 24 | + * @property integer $updated_at | ||
| 25 | + * @property integer $deleted_at | ||
| 26 | + * @property integer $sort | ||
| 27 | + * @property boolean $status | ||
| 28 | + * @property integer $author_id | ||
| 29 | + * @property integer $image_id | ||
| 30 | + * @property EventLang[] $blogArticleLangs | ||
| 31 | + * @property Language[] $languages | ||
| 32 | + * @property Event[] $relatedBlogArticles | ||
| 33 | + * @property Event[] $articles | ||
| 34 | + * @property Tag[] $tags | ||
| 35 | + * * from VariationBehavior | ||
| 36 | + * @method ActiveQuery hasDefaultVariationRelation(); | ||
| 37 | + */ | ||
| 38 | + class Event extends ActiveRecord | ||
| 39 | + { | ||
| 40 | + use AliasableTrait; | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * @inheritdoc | ||
| 44 | + */ | ||
| 45 | + public static function tableName() | ||
| 46 | + { | ||
| 47 | + return 'event'; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public function behaviors() | ||
| 51 | + { | ||
| 52 | + return [ | ||
| 53 | + 'translations' => [ | ||
| 54 | + 'class' => VariationBehavior::className(), | ||
| 55 | + 'variationsRelation' => 'languages', | ||
| 56 | + 'defaultVariationRelation' => 'language', | ||
| 57 | + 'variationOptionReferenceAttribute' => 'language_id', | ||
| 58 | + 'optionModelClass' => Language::className(), | ||
| 59 | + 'defaultVariationOptionReference' => function () { | ||
| 60 | + return Language::getCurrent()->id; | ||
| 61 | + }, | ||
| 62 | + 'optionQueryFilter' => function (ActiveQuery $query) { | ||
| 63 | + $query->where( | ||
| 64 | + [ | ||
| 65 | + 'status' => true, | ||
| 66 | + ] | ||
| 67 | + ); | ||
| 68 | + }, | ||
| 69 | + ], | ||
| 70 | + 'positionBehavior' => [ | ||
| 71 | + 'class' => PositionBehavior::className(), | ||
| 72 | + 'positionAttribute' => 'sort', | ||
| 73 | + ], | ||
| 74 | + 'linkTagBehavior' => [ | ||
| 75 | + 'class' => LinkManyBehavior::className(), | ||
| 76 | + 'relation' => 'tags', | ||
| 77 | + 'relationReferenceAttribute' => 'tagIds', | ||
| 78 | + ], | ||
| 79 | + 'timestamp' => [ | ||
| 80 | + 'class' => TimestampBehavior::className(), | ||
| 81 | + ], | ||
| 82 | + ]; | ||
| 83 | + } | ||
| 84 | + /** | ||
| 85 | + * @inheritdoc | ||
| 86 | + */ | ||
| 87 | + public function rules() | ||
| 88 | + { | ||
| 89 | + return [ | ||
| 90 | + [ | ||
| 91 | + [ | ||
| 92 | + 'created_at', | ||
| 93 | + 'updated_at', | ||
| 94 | + 'deleted_at', | ||
| 95 | + 'sort', | ||
| 96 | + 'author_id', | ||
| 97 | + 'image_id', | ||
| 98 | + ], | ||
| 99 | + 'integer', | ||
| 100 | + ], | ||
| 101 | + [ | ||
| 102 | + [ 'status' ], | ||
| 103 | + 'boolean', | ||
| 104 | + ], | ||
| 105 | + | ||
| 106 | + [ | ||
| 107 | + [ | ||
| 108 | + 'tagIds', | ||
| 109 | + ], | ||
| 110 | + 'safe', | ||
| 111 | + ], | ||
| 112 | + ]; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + /** | ||
| 116 | + * @inheritdoc | ||
| 117 | + */ | ||
| 118 | + public function attributeLabels() | ||
| 119 | + { | ||
| 120 | + return [ | ||
| 121 | + 'id' => 'ID', | ||
| 122 | + 'image' => 'Image', | ||
| 123 | + 'created_at' => 'Created At', | ||
| 124 | + 'updated_at' => \Yii::t('core', 'Updated At'), | ||
| 125 | + 'deleted_at' => 'Deleted At', | ||
| 126 | + 'sort' => \Yii::t('core', 'Sort'), | ||
| 127 | + 'status' => \Yii::t('core', 'Status'), | ||
| 128 | + 'author_id' => 'Author ID', | ||
| 129 | + 'title' => \Yii::t('core', 'Title'), | ||
| 130 | + 'tags' => \Yii::t('core', 'Tags'), | ||
| 131 | + | ||
| 132 | + 'image_id' => \Yii::t('core', 'Image'), | ||
| 133 | + 'tagIds' => \Yii::t('core', 'Tags'), | ||
| 134 | + ]; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public function getLanguages() | ||
| 138 | + { | ||
| 139 | + return $this->hasMany(EventLang::className(), [ 'event_id' => 'id' ]); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * @return \yii\db\ActiveQuery | ||
| 144 | + */ | ||
| 145 | + public function getLanguage() | ||
| 146 | + { | ||
| 147 | + return $this->hasDefaultVariationRelation(); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + | ||
| 151 | + public function getRoute() | ||
| 152 | + { | ||
| 153 | + return Json::encode( | ||
| 154 | + [ | ||
| 155 | + 'event/view', | ||
| 156 | + 'id' => $this->id, | ||
| 157 | + ] | ||
| 158 | + ); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + | ||
| 162 | + | ||
| 163 | + | ||
| 164 | + | ||
| 165 | + /** | ||
| 166 | + * @return \yii\db\ActiveQuery | ||
| 167 | + */ | ||
| 168 | + public function getImage() | ||
| 169 | + { | ||
| 170 | + return $this->hasOne(Image::className(), [ 'id' => 'image_id' ]); | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + | ||
| 174 | + | ||
| 175 | + | ||
| 176 | + /** | ||
| 177 | + * @return \yii\db\ActiveQuery | ||
| 178 | + */ | ||
| 179 | + public function getTags() | ||
| 180 | + { | ||
| 181 | + return $this->hasMany(Tag::className(), [ 'id' => 'event_tag_id' ]) | ||
| 182 | + ->viaTable('event_to_tag', [ 'event_id' => 'id' ]); | ||
| 183 | + } | ||
| 184 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace common\models\event; | ||
| 4 | + | ||
| 5 | + use artbox\core\models\Alias; | ||
| 6 | + use artbox\core\models\Language; | ||
| 7 | + use yii\db\ActiveRecord; | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * This is the model class for table "blog_article_lang". | ||
| 11 | + * | ||
| 12 | + * @property integer $id | ||
| 13 | + * @property integer $blog_article_id | ||
| 14 | + * @property integer $language_id | ||
| 15 | + * @property string $title | ||
| 16 | + * @property string $body | ||
| 17 | + * @property string $body_preview | ||
| 18 | + * @property string $meta_title | ||
| 19 | + * @property string $meta_description | ||
| 20 | + * @property string $h1 | ||
| 21 | + * @property string $seo_text | ||
| 22 | + * @property Event $article | ||
| 23 | + * @property Language $language | ||
| 24 | + * @property Alias $alias | ||
| 25 | + */ | ||
| 26 | + class EventLang extends ActiveRecord | ||
| 27 | + { | ||
| 28 | + /** | ||
| 29 | + * @inheritdoc | ||
| 30 | + */ | ||
| 31 | + public static function tableName() | ||
| 32 | + { | ||
| 33 | + return 'event_lang'; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @inheritdoc | ||
| 38 | + */ | ||
| 39 | + public function rules() | ||
| 40 | + { | ||
| 41 | + return [ | ||
| 42 | + [ | ||
| 43 | + [ | ||
| 44 | + 'title', | ||
| 45 | + ], | ||
| 46 | + 'required', | ||
| 47 | + ], | ||
| 48 | + [ | ||
| 49 | + [ | ||
| 50 | + 'body', | ||
| 51 | + 'body_preview', | ||
| 52 | + ], | ||
| 53 | + 'string', | ||
| 54 | + ], | ||
| 55 | + [ | ||
| 56 | + [ | ||
| 57 | + 'title', | ||
| 58 | + ], | ||
| 59 | + 'string', | ||
| 60 | + 'max' => 80, | ||
| 61 | + ], | ||
| 62 | + | ||
| 63 | + ]; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public function attributeLabels() | ||
| 67 | + { | ||
| 68 | + return [ | ||
| 69 | + 'title' => \Yii::t('core', 'Title'), | ||
| 70 | + 'body' => \Yii::t('core', 'Body'), | ||
| 71 | + 'body_preview' => \Yii::t('core', 'Body Preview'), | ||
| 72 | + ]; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * @return \yii\db\ActiveQuery | ||
| 77 | + */ | ||
| 78 | + public function getAlias() | ||
| 79 | + { | ||
| 80 | + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]); | ||
| 81 | + } | ||
| 82 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace common\models\event; | ||
| 4 | + | ||
| 5 | + use artbox\core\models\traits\AliasableTrait; | ||
| 6 | + use yii\db\ActiveRecord; | ||
| 7 | + use artbox\core\models\Language; | ||
| 8 | + use yii\db\ActiveQuery; | ||
| 9 | + use yii\helpers\Json; | ||
| 10 | + use yii2tech\ar\position\PositionBehavior; | ||
| 11 | + use yii2tech\ar\variation\VariationBehavior; | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * This is the model class for table "blog_tag". | ||
| 15 | + * | ||
| 16 | + * @property integer $id | ||
| 17 | + * @property Event[] $articles | ||
| 18 | + * @property TagLang[] $blogTagLangs | ||
| 19 | + * @property Language[] $languages | ||
| 20 | + * * * from VariationBehavior | ||
| 21 | + * @method ActiveQuery hasDefaultVariationRelation(); | ||
| 22 | + */ | ||
| 23 | + class Tag extends ActiveRecord | ||
| 24 | + { | ||
| 25 | + use AliasableTrait; | ||
| 26 | + /** | ||
| 27 | + * @inheritdoc | ||
| 28 | + */ | ||
| 29 | + public static function tableName() | ||
| 30 | + { | ||
| 31 | + return 'event_tag'; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * @inheritdoc | ||
| 36 | + */ | ||
| 37 | + public function behaviors() | ||
| 38 | + { | ||
| 39 | + return [ | ||
| 40 | + 'translations' => [ | ||
| 41 | + 'class' => VariationBehavior::className(), | ||
| 42 | + 'variationsRelation' => 'languages', | ||
| 43 | + 'defaultVariationRelation' => 'language', | ||
| 44 | + 'variationOptionReferenceAttribute' => 'language_id', | ||
| 45 | + 'optionModelClass' => Language::className(), | ||
| 46 | + 'defaultVariationOptionReference' => function () { | ||
| 47 | + return Language::getCurrent()->id; | ||
| 48 | + }, | ||
| 49 | + 'optionQueryFilter' => function (ActiveQuery $query) { | ||
| 50 | + $query->where( | ||
| 51 | + [ | ||
| 52 | + 'status' => true, | ||
| 53 | + ] | ||
| 54 | + ); | ||
| 55 | + }, | ||
| 56 | + ], | ||
| 57 | + 'positionBehavior' => [ | ||
| 58 | + 'class' => PositionBehavior::className(), | ||
| 59 | + 'positionAttribute' => 'sort', | ||
| 60 | + ], | ||
| 61 | + ]; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * @inheritdoc | ||
| 66 | + */ | ||
| 67 | + public function rules() | ||
| 68 | + { | ||
| 69 | + return [ | ||
| 70 | + [ | ||
| 71 | + [ | ||
| 72 | + 'id', | ||
| 73 | + 'sort', | ||
| 74 | + ], | ||
| 75 | + 'integer', | ||
| 76 | + ], | ||
| 77 | + ]; | ||
| 78 | + } | ||
| 79 | + public function getRoute() | ||
| 80 | + { | ||
| 81 | + return Json::encode( | ||
| 82 | + [ | ||
| 83 | + 'event/tag', | ||
| 84 | + 'id' => $this->id, | ||
| 85 | + ] | ||
| 86 | + ); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + /** | ||
| 90 | + * @inheritdoc | ||
| 91 | + */ | ||
| 92 | + public function attributeLabels() | ||
| 93 | + { | ||
| 94 | + return [ | ||
| 95 | + 'id' => 'ID', | ||
| 96 | + 'label' => \Yii::t('core', 'Label'), | ||
| 97 | + 'sort' => \Yii::t('core', 'Sort'), | ||
| 98 | + ]; | ||
| 99 | + } | ||
| 100 | + /** | ||
| 101 | + * @return \yii\db\ActiveQuery | ||
| 102 | + */ | ||
| 103 | + public function getLanguages() | ||
| 104 | + { | ||
| 105 | + return $this->hasMany(TagLang::className(), [ 'blog_tag_id' => 'id' ]); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + /** | ||
| 109 | + * @return \yii\db\ActiveQuery | ||
| 110 | + */ | ||
| 111 | + public function getLanguage() | ||
| 112 | + { | ||
| 113 | + return $this->hasDefaultVariationRelation(); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * @return \yii\db\ActiveQuery | ||
| 118 | + */ | ||
| 119 | + public function getArticles() | ||
| 120 | + { | ||
| 121 | + return $this->hasMany(Event::className(), [ 'id' => 'event_id' ]) | ||
| 122 | + ->viaTable('event_to_tag', [ 'event_tag_id' => 'id' ]); | ||
| 123 | + } | ||
| 124 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace common\models\event; | ||
| 4 | + | ||
| 5 | + use artbox\core\models\Alias; | ||
| 6 | + use artbox\core\models\Language; | ||
| 7 | + use yii\db\ActiveRecord; | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * This is the model class for table "blog_tag_lang". | ||
| 11 | + * | ||
| 12 | + * @property integer $id | ||
| 13 | + * @property integer $blog_tag_id | ||
| 14 | + * @property integer $language_id | ||
| 15 | + * @property string $label | ||
| 16 | + * @property Tag $blogTag | ||
| 17 | + * @property Language $language | ||
| 18 | + */ | ||
| 19 | + class TagLang extends ActiveRecord | ||
| 20 | + { | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * @inheritdoc | ||
| 24 | + */ | ||
| 25 | + public static function tableName() | ||
| 26 | + { | ||
| 27 | + return 'event_tag_lang'; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * @inheritdoc | ||
| 32 | + */ | ||
| 33 | + public function rules() | ||
| 34 | + { | ||
| 35 | + return [ | ||
| 36 | + [ | ||
| 37 | + [ 'title' ], | ||
| 38 | + 'string', | ||
| 39 | + 'max' => 255, | ||
| 40 | + ], | ||
| 41 | + ]; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @inheritdoc | ||
| 46 | + */ | ||
| 47 | + public function attributeLabels() | ||
| 48 | + { | ||
| 49 | + return [ | ||
| 50 | + 'id' => 'ID', | ||
| 51 | + 'blog_tag_id' => 'Blog Tag ID', | ||
| 52 | + 'language_id' => 'Language ID', | ||
| 53 | + 'title' => \Yii::t('core', 'Title'), | ||
| 54 | + ]; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * @return \yii\db\ActiveQuery | ||
| 59 | + */ | ||
| 60 | + public function getTag() | ||
| 61 | + { | ||
| 62 | + return $this->hasOne(Tag::className(), [ 'id' => 'event_tag_id' ]); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public function getAlias() | ||
| 66 | + { | ||
| 67 | + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * @return \yii\db\ActiveQuery | ||
| 72 | + */ | ||
| 73 | + public function getLanguage() | ||
| 74 | + { | ||
| 75 | + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); | ||
| 76 | + } | ||
| 77 | + } |
common/models/slider/Slide.php
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace common\models\slider; | 3 | namespace common\models\slider; |
| 4 | 4 | ||
| 5 | + use artbox\core\models\Image; | ||
| 5 | use artbox\core\models\Language; | 6 | use artbox\core\models\Language; |
| 6 | use yii\db\ActiveQuery; | 7 | use yii\db\ActiveQuery; |
| 7 | use yii\db\ActiveRecord; | 8 | use yii\db\ActiveRecord; |
| @@ -72,6 +73,14 @@ | @@ -72,6 +73,14 @@ | ||
| 72 | [ 'status' ], | 73 | [ 'status' ], |
| 73 | 'boolean', | 74 | 'boolean', |
| 74 | ], | 75 | ], |
| 76 | + [ | ||
| 77 | + [ 'background_id' ], | ||
| 78 | + 'required', | ||
| 79 | + ], | ||
| 80 | + [ | ||
| 81 | + [ 'background_id' ], | ||
| 82 | + 'integer', | ||
| 83 | + ], | ||
| 75 | ]; | 84 | ]; |
| 76 | } | 85 | } |
| 77 | 86 | ||
| @@ -86,6 +95,7 @@ | @@ -86,6 +95,7 @@ | ||
| 86 | 'sort' => \Yii::t('core', 'Sort'), | 95 | 'sort' => \Yii::t('core', 'Sort'), |
| 87 | 'title' => \Yii::t('core', 'Title'), | 96 | 'title' => \Yii::t('core', 'Title'), |
| 88 | 'link' => \Yii::t('core', 'Link'), | 97 | 'link' => \Yii::t('core', 'Link'), |
| 98 | + 'background_id' => \Yii::t('core', 'Background'), | ||
| 89 | ]; | 99 | ]; |
| 90 | } | 100 | } |
| 91 | 101 | ||
| @@ -110,4 +120,12 @@ | @@ -110,4 +120,12 @@ | ||
| 110 | return $this->hasMany(SlideLang::className(), [ 'slide_id' => 'id' ]) | 120 | return $this->hasMany(SlideLang::className(), [ 'slide_id' => 'id' ]) |
| 111 | ->inverseOf('slide'); | 121 | ->inverseOf('slide'); |
| 112 | } | 122 | } |
| 123 | + | ||
| 124 | + /** | ||
| 125 | + * @return \yii\db\ActiveQuery | ||
| 126 | + */ | ||
| 127 | + public function getBackground() | ||
| 128 | + { | ||
| 129 | + return $this->hasOne(Image::className(), [ 'id' => 'image_id' ]); | ||
| 130 | + } | ||
| 113 | } | 131 | } |
common/models/slider/SlideLang.php
| @@ -39,12 +39,6 @@ | @@ -39,12 +39,6 @@ | ||
| 39 | [ | 39 | [ |
| 40 | 'image_id', | 40 | 'image_id', |
| 41 | ], | 41 | ], |
| 42 | - 'required', | ||
| 43 | - ], | ||
| 44 | - [ | ||
| 45 | - [ | ||
| 46 | - 'image_id', | ||
| 47 | - ], | ||
| 48 | 'integer', | 42 | 'integer', |
| 49 | ], | 43 | ], |
| 50 | [ | 44 | [ |
| @@ -55,6 +49,10 @@ | @@ -55,6 +49,10 @@ | ||
| 55 | 'string', | 49 | 'string', |
| 56 | 'max' => 255, | 50 | 'max' => 255, |
| 57 | ], | 51 | ], |
| 52 | + [ | ||
| 53 | + [ 'description' ], | ||
| 54 | + 'string' | ||
| 55 | + ] | ||
| 58 | ]; | 56 | ]; |
| 59 | } | 57 | } |
| 60 | 58 | ||
| @@ -69,6 +67,7 @@ | @@ -69,6 +67,7 @@ | ||
| 69 | 'link' => Yii::t('core', 'Link'), | 67 | 'link' => Yii::t('core', 'Link'), |
| 70 | 'image_id' => Yii::t('core', 'Image'), | 68 | 'image_id' => Yii::t('core', 'Image'), |
| 71 | 'title' => Yii::t('core', 'Title'), | 69 | 'title' => Yii::t('core', 'Title'), |
| 70 | + 'description' => Yii::t('core', 'Description'), | ||
| 72 | ]; | 71 | ]; |
| 73 | } | 72 | } |
| 74 | 73 |
console/migrations/m180507_115504_create_gallery_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Handles the creation of table `gallery`. | ||
| 7 | + */ | ||
| 8 | +class m180507_115504_create_gallery_table extends Migration | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * {@inheritdoc} | ||
| 12 | + */ | ||
| 13 | + public function safeUp() | ||
| 14 | + { | ||
| 15 | + $this->createTable('gallery', [ | ||
| 16 | + 'id' => $this->primaryKey(), | ||
| 17 | + 'image_id' => $this->integer(), | ||
| 18 | + 'sort' => $this->integer(), | ||
| 19 | + 'status' => $this->boolean(), | ||
| 20 | + ]); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * {@inheritdoc} | ||
| 25 | + */ | ||
| 26 | + public function safeDown() | ||
| 27 | + { | ||
| 28 | + $this->dropTable('gallery'); | ||
| 29 | + } | ||
| 30 | +} |
console/migrations/m180507_120119_create_gallery_lang_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Handles the creation of table `gallery_lang`. | ||
| 7 | + */ | ||
| 8 | +class m180507_120119_create_gallery_lang_table extends Migration | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * {@inheritdoc} | ||
| 12 | + */ | ||
| 13 | + public function safeUp() | ||
| 14 | + { | ||
| 15 | + $this->createTable('gallery_lang', [ | ||
| 16 | + 'gallery_id' => $this->integer() | ||
| 17 | + ->notNull(), | ||
| 18 | + 'language_id' => $this->integer() | ||
| 19 | + ->notNull(), | ||
| 20 | + 'title' => $this->string(), | ||
| 21 | + 'PRIMARY KEY(gallery_id, language_id)', | ||
| 22 | + ]); | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + $this->addForeignKey( | ||
| 27 | + 'gallery_lang_fk', | ||
| 28 | + 'gallery_lang', | ||
| 29 | + 'language_id', | ||
| 30 | + 'language', | ||
| 31 | + 'id', | ||
| 32 | + 'RESTRICT', | ||
| 33 | + 'CASCADE' | ||
| 34 | + ); | ||
| 35 | + | ||
| 36 | + $this->addForeignKey( | ||
| 37 | + 'gallery_fk', | ||
| 38 | + 'gallery_lang', | ||
| 39 | + 'gallery_id', | ||
| 40 | + 'gallery', | ||
| 41 | + 'id', | ||
| 42 | + 'CASCADE', | ||
| 43 | + 'CASCADE' | ||
| 44 | + ); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * {@inheritdoc} | ||
| 49 | + */ | ||
| 50 | + public function safeDown() | ||
| 51 | + { | ||
| 52 | + $this->dropForeignKey('gallery_lang_fk', 'gallery_lang'); | ||
| 53 | + $this->dropForeignKey('gallery_fk', 'gallery_lang'); | ||
| 54 | + $this->dropTable('gallery_lang'); | ||
| 55 | + } | ||
| 56 | +} |
console/migrations/m180507_122728_create_event_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Handles the creation of table `event`. | ||
| 7 | + */ | ||
| 8 | +class m180507_122728_create_event_table extends Migration | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * {@inheritdoc} | ||
| 12 | + */ | ||
| 13 | + public function safeUp() | ||
| 14 | + { | ||
| 15 | + $this->createTable('event', [ | ||
| 16 | + 'id' => $this->primaryKey(), | ||
| 17 | + 'image_id' => $this->integer(), | ||
| 18 | + 'created_at' => $this->integer(), | ||
| 19 | + 'updated_at' => $this->integer(), | ||
| 20 | + 'deleted_at' => $this->integer(), | ||
| 21 | + 'sort' => $this->integer(), | ||
| 22 | + 'status' => $this->boolean(), | ||
| 23 | + 'author_id' => $this->integer(), | ||
| 24 | + ]); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * {@inheritdoc} | ||
| 29 | + */ | ||
| 30 | + public function safeDown() | ||
| 31 | + { | ||
| 32 | + $this->dropTable('event'); | ||
| 33 | + } | ||
| 34 | +} |
console/migrations/m180507_123248_create_event_lang_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Handles the creation of table `event_lang`. | ||
| 7 | + */ | ||
| 8 | +class m180507_123248_create_event_lang_table extends Migration | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * {@inheritdoc} | ||
| 12 | + */ | ||
| 13 | + public function safeUp() | ||
| 14 | + { | ||
| 15 | + $this->createTable('event_lang', [ | ||
| 16 | + 'id' => $this->primaryKey(), | ||
| 17 | + 'event_id' => $this->integer() | ||
| 18 | + ->notNull(), | ||
| 19 | + 'language_id' => $this->integer() | ||
| 20 | + ->notNull(), | ||
| 21 | + 'title' => $this->string(255), | ||
| 22 | + 'body' => $this->text(), | ||
| 23 | + 'body_preview' => $this->text(), | ||
| 24 | + 'alias_id' => $this->integer(), | ||
| 25 | + ]); | ||
| 26 | + | ||
| 27 | + $this->createIndex( | ||
| 28 | + 'event_lang_uk', | ||
| 29 | + 'event_lang', | ||
| 30 | + [ | ||
| 31 | + 'event_id', | ||
| 32 | + 'language_id', | ||
| 33 | + ], | ||
| 34 | + true | ||
| 35 | + ); | ||
| 36 | + | ||
| 37 | + $this->createIndex( | ||
| 38 | + 'event_alias_uk', | ||
| 39 | + 'event_lang', | ||
| 40 | + 'alias_id', | ||
| 41 | + true | ||
| 42 | + ); | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Add foreign keys in blog_articles and language tables | ||
| 46 | + */ | ||
| 47 | + $this->addForeignKey( | ||
| 48 | + 'event_fk', | ||
| 49 | + 'event_lang', | ||
| 50 | + 'event_id', | ||
| 51 | + 'event', | ||
| 52 | + 'id', | ||
| 53 | + 'CASCADE', | ||
| 54 | + 'CASCADE' | ||
| 55 | + ); | ||
| 56 | + | ||
| 57 | + $this->addForeignKey( | ||
| 58 | + 'event_lang_fk', | ||
| 59 | + 'event_lang', | ||
| 60 | + 'language_id', | ||
| 61 | + 'language', | ||
| 62 | + 'id', | ||
| 63 | + 'RESTRICT', | ||
| 64 | + 'CASCADE' | ||
| 65 | + ); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * {@inheritdoc} | ||
| 70 | + */ | ||
| 71 | + public function safeDown() | ||
| 72 | + { | ||
| 73 | + $this->dropForeignKey('event_lang_fk', 'event_lang'); | ||
| 74 | + $this->dropForeignKey('event_fk', 'event_lang'); | ||
| 75 | + $this->dropIndex('event_alias_uk', 'event_lang'); | ||
| 76 | + $this->dropIndex('event_lang_uk', 'event_lang'); | ||
| 77 | + $this->dropTable('event_lang'); | ||
| 78 | + } | ||
| 79 | +} |
console/migrations/m180507_123642_create_event_tag_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Handles the creation of table `event_tag`. | ||
| 7 | + */ | ||
| 8 | +class m180507_123642_create_event_tag_table extends Migration | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * {@inheritdoc} | ||
| 12 | + */ | ||
| 13 | + public function safeUp() | ||
| 14 | + { | ||
| 15 | + $this->createTable('event_tag', [ | ||
| 16 | + 'id' => $this->primaryKey(), | ||
| 17 | + 'sort' => $this->integer() | ||
| 18 | + ]); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * {@inheritdoc} | ||
| 23 | + */ | ||
| 24 | + public function safeDown() | ||
| 25 | + { | ||
| 26 | + $this->dropTable('event_tag'); | ||
| 27 | + } | ||
| 28 | +} |
console/migrations/m180507_123737_create_event_tag_lang_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Handles the creation of table `event_tag_lang`. | ||
| 7 | + */ | ||
| 8 | +class m180507_123737_create_event_tag_lang_table extends Migration | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * {@inheritdoc} | ||
| 12 | + */ | ||
| 13 | + public function safeUp() | ||
| 14 | + { | ||
| 15 | + $this->createTable('event_tag_lang', [ | ||
| 16 | + 'id' => $this->primaryKey(), | ||
| 17 | + 'event_tag_id' => $this->integer() | ||
| 18 | + ->notNull(), | ||
| 19 | + 'language_id' => $this->integer() | ||
| 20 | + ->notNull(), | ||
| 21 | + 'alias_id' => $this->integer(), | ||
| 22 | + 'label' => $this->string(255), | ||
| 23 | + ]); | ||
| 24 | + | ||
| 25 | + $this->createIndex( | ||
| 26 | + 'event_tag_lang_uk', | ||
| 27 | + 'event_tag_lang', | ||
| 28 | + [ | ||
| 29 | + 'event_tag_id', | ||
| 30 | + 'language_id', | ||
| 31 | + ], | ||
| 32 | + true | ||
| 33 | + ); | ||
| 34 | + | ||
| 35 | + $this->createIndex('event_tag_lang_auk', 'event_tag_lang', 'alias_id', true); | ||
| 36 | + | ||
| 37 | + $this->addForeignKey( | ||
| 38 | + 'event_tag_lang_fk', | ||
| 39 | + 'event_tag_lang', | ||
| 40 | + 'language_id', | ||
| 41 | + 'language', | ||
| 42 | + 'id', | ||
| 43 | + 'RESTRICT', | ||
| 44 | + 'CASCADE' | ||
| 45 | + ); | ||
| 46 | + | ||
| 47 | + $this->addForeignKey( | ||
| 48 | + 'event_tag_fk', | ||
| 49 | + 'event_tag_lang', | ||
| 50 | + 'event_tag_id', | ||
| 51 | + 'event_tag', | ||
| 52 | + 'id', | ||
| 53 | + 'CASCADE', | ||
| 54 | + 'CASCADE' | ||
| 55 | + ); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * {@inheritdoc} | ||
| 60 | + */ | ||
| 61 | + public function safeDown() | ||
| 62 | + { | ||
| 63 | + $this->dropForeignKey('event_tag_fk', 'event_tag_lang'); | ||
| 64 | + $this->dropForeignKey('event_tag_lang_fk', 'event_tag_lang'); | ||
| 65 | + $this->dropIndex('event_tag_lang_uk', 'event_tag_lang'); | ||
| 66 | + $this->dropTable('event_tag_lang'); | ||
| 67 | + } | ||
| 68 | +} |
console/migrations/m180507_124405_create_event_to_tag_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Handles the creation of table `event_to_tag`. | ||
| 7 | + */ | ||
| 8 | +class m180507_124405_create_event_to_tag_table extends Migration | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * {@inheritdoc} | ||
| 12 | + */ | ||
| 13 | + public function safeUp() | ||
| 14 | + { | ||
| 15 | + $this->createTable('event_to_tag', [ | ||
| 16 | + 'event_id' => $this->integer() | ||
| 17 | + ->notNull(), | ||
| 18 | + 'event_tag_id' => $this->integer() | ||
| 19 | + ->notNull(), | ||
| 20 | + ]); | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * Create indexes and foreign keys for junction table | ||
| 24 | + */ | ||
| 25 | + $this->createIndex( | ||
| 26 | + 'event_to_tag_uk', | ||
| 27 | + 'event_to_tag', | ||
| 28 | + [ | ||
| 29 | + 'event_id', | ||
| 30 | + 'event_tag_id', | ||
| 31 | + ], | ||
| 32 | + true | ||
| 33 | + ); | ||
| 34 | + | ||
| 35 | + $this->addForeignKey( | ||
| 36 | + 'event_to_tag_tag_fk', | ||
| 37 | + 'event_to_tag', | ||
| 38 | + 'event_tag_id', | ||
| 39 | + 'event_tag', | ||
| 40 | + 'id', | ||
| 41 | + 'CASCADE', | ||
| 42 | + 'CASCADE' | ||
| 43 | + ); | ||
| 44 | + | ||
| 45 | + $this->addForeignKey( | ||
| 46 | + 'event_to_tag_art_fk', | ||
| 47 | + 'event_to_tag', | ||
| 48 | + 'event_id', | ||
| 49 | + 'event', | ||
| 50 | + 'id', | ||
| 51 | + 'CASCADE', | ||
| 52 | + 'CASCADE' | ||
| 53 | + ); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * {@inheritdoc} | ||
| 58 | + */ | ||
| 59 | + public function safeDown() | ||
| 60 | + { | ||
| 61 | + $this->dropForeignKey('event_to_tag_art_fk', 'event_to_tag'); | ||
| 62 | + $this->dropForeignKey('event_to_tag_tag_fk', 'event_to_tag'); | ||
| 63 | + $this->dropIndex('event_to_tag_uk', 'event_to_tag'); | ||
| 64 | + $this->dropTable('event_to_tag'); | ||
| 65 | + } | ||
| 66 | +} |
console/migrations/m180507_131039_alter_tables_slide.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Class m180507_131039_alter_tables_slide | ||
| 7 | + */ | ||
| 8 | +class m180507_131039_alter_tables_slide extends Migration | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * {@inheritdoc} | ||
| 12 | + */ | ||
| 13 | + public function safeUp() | ||
| 14 | + { | ||
| 15 | + $this->addColumn('slide', 'background_id', $this->integer()); | ||
| 16 | + $this->addColumn('slide_lang', 'description', $this->text()); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * {@inheritdoc} | ||
| 21 | + */ | ||
| 22 | + public function safeDown() | ||
| 23 | + { | ||
| 24 | + $this->dropColumn('slide', 'background_id'); | ||
| 25 | + $this->dropColumn('slide_lang', 'description'); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /* | ||
| 29 | + // Use up()/down() to run migration code without a transaction. | ||
| 30 | + public function up() | ||
| 31 | + { | ||
| 32 | + | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public function down() | ||
| 36 | + { | ||
| 37 | + echo "m180507_131039_alter_tables_slide cannot be reverted.\n"; | ||
| 38 | + | ||
| 39 | + return false; | ||
| 40 | + } | ||
| 41 | + */ | ||
| 42 | +} |
frontend/controllers/BlogController.php
| @@ -40,12 +40,12 @@ | @@ -40,12 +40,12 @@ | ||
| 40 | $dataProvider = new ActiveDataProvider( | 40 | $dataProvider = new ActiveDataProvider( |
| 41 | [ | 41 | [ |
| 42 | 'query' => Article::find() | 42 | 'query' => Article::find() |
| 43 | - ->orderBy( | 43 | + ->orderBy( |
| 44 | [ | 44 | [ |
| 45 | 'created_at' => SORT_DESC, | 45 | 'created_at' => SORT_DESC, |
| 46 | ] | 46 | ] |
| 47 | ) | 47 | ) |
| 48 | - ->with( | 48 | + ->with( |
| 49 | [ | 49 | [ |
| 50 | 'categories.language', | 50 | 'categories.language', |
| 51 | ] | 51 | ] |
| @@ -225,16 +225,16 @@ | @@ -225,16 +225,16 @@ | ||
| 225 | * @var Article | null $model | 225 | * @var Article | null $model |
| 226 | */ | 226 | */ |
| 227 | $model = Article::find() | 227 | $model = Article::find() |
| 228 | - ->where([ 'id' => $id ]) | ||
| 229 | - ->with( | 228 | + ->where([ 'id' => $id ]) |
| 229 | + ->with( | ||
| 230 | [ | 230 | [ |
| 231 | 'language', | 231 | 'language', |
| 232 | 'categories.language', | 232 | 'categories.language', |
| 233 | 'tags.language', | 233 | 'tags.language', |
| 234 | ] | 234 | ] |
| 235 | ) | 235 | ) |
| 236 | - ->andWhere([ 'status' => true ]) | ||
| 237 | - ->one(); | 236 | + ->andWhere([ 'status' => true ]) |
| 237 | + ->one(); | ||
| 238 | 238 | ||
| 239 | if (empty($model)) { | 239 | if (empty($model)) { |
| 240 | throw new NotFoundHttpException(\Yii::t('app', 'Article not found')); | 240 | throw new NotFoundHttpException(\Yii::t('app', 'Article not found')); |
frontend/controllers/SiteController.php
| @@ -53,11 +53,11 @@ | @@ -53,11 +53,11 @@ | ||
| 53 | { | 53 | { |
| 54 | $slides = Slide::find()->with('language')->where(['status' => true])->orderBy('sort')->all(); | 54 | $slides = Slide::find()->with('language')->where(['status' => true])->orderBy('sort')->all(); |
| 55 | $articles = Article::find() | 55 | $articles = Article::find() |
| 56 | - ->with('language') | ||
| 57 | - ->where([ 'status' => true ]) | ||
| 58 | - ->orderBy('sort DESC') | ||
| 59 | - ->limit(4) | ||
| 60 | - ->all(); | 56 | + ->with('language') |
| 57 | + ->where([ 'status' => true ]) | ||
| 58 | + ->orderBy('sort DESC') | ||
| 59 | + ->limit(4) | ||
| 60 | + ->all(); | ||
| 61 | return $this->render('index', [ | 61 | return $this->render('index', [ |
| 62 | 'slides' => $slides, | 62 | 'slides' => $slides, |
| 63 | 'articles' => $articles | 63 | 'articles' => $articles |
frontend/views/blog/view.php
| @@ -7,9 +7,9 @@ | @@ -7,9 +7,9 @@ | ||
| 7 | use yii\web\View; | 7 | use yii\web\View; |
| 8 | 8 | ||
| 9 | /** | 9 | /** |
| 10 | - * @var View $this | 10 | + * @var View $this |
| 11 | * @var Article $model | 11 | * @var Article $model |
| 12 | - * @var Tag[] $tags | 12 | + * @var Tag[] $tags |
| 13 | */ | 13 | */ |
| 14 | 14 | ||
| 15 | $this->params[ 'breadcrumbs' ][] = [ | 15 | $this->params[ 'breadcrumbs' ][] = [ |
frontend/views/layouts/main.php
| @@ -250,6 +250,11 @@ _________________________________________________________ --> | @@ -250,6 +250,11 @@ _________________________________________________________ --> | ||
| 250 | } else { | 250 | } else { |
| 251 | echo ' href="/en"'; | 251 | echo ' href="/en"'; |
| 252 | } ?>>en</a> | 252 | } ?>>en</a> |
| 253 | + <a<?php if ($lang[ '0' ] == 'ua') { | ||
| 254 | + echo ' class="active"'; | ||
| 255 | + } else { | ||
| 256 | + echo ' href="/ua"'; | ||
| 257 | + } ?>>ua</a> | ||
| 253 | </div> | 258 | </div> |
| 254 | </div> | 259 | </div> |
| 255 | </div> | 260 | </div> |
frontend/views/site/index.php
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | /* @var $this yii\web\View | 3 | /* @var $this yii\web\View |
| 4 | * @var \common\models\slider\Slide[] $slides; | 4 | * @var \common\models\slider\Slide[] $slides; |
| 5 | - * @var \common\models\blog\Article[] $articles | 5 | + * @var \common\models\blog\Article[] $articles |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | use artbox\core\helpers\ImageHelper; | 8 | use artbox\core\helpers\ImageHelper; |