From c5a6465c805db4ee441f9fa1749840c4f6e16362 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 1 Nov 2016 18:47:23 +0200 Subject: [PATCH] -Blog half-way done --- backend/config/test-local.php | 0 backend/views/layouts/main-sidebar.php | 23 +++++++++++++++++++++++ backup_leha.sql | 0 common/config/main.php | 3 +++ common/config/test-local.php | 0 common/modules/blog/Module.php | 24 ++++++++++++++++++++++++ common/modules/blog/controllers/BlogArticleController.php | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/controllers/BlogCategoryController.php | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/controllers/BlogTagController.php | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/controllers/DefaultController.php | 20 ++++++++++++++++++++ common/modules/blog/models/BlogArticle.php | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/models/BlogArticleLang.php | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/models/BlogArticleSearch.php | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/models/BlogCategory.php | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/models/BlogCategoryLang.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/models/BlogCategorySearch.php | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/models/BlogTag.php | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/models/BlogTagLang.php | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/models/BlogTagSearch.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-article/_form.php | 35 +++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-article/_search.php | 41 +++++++++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-article/create.php | 21 +++++++++++++++++++++ common/modules/blog/views/blog-article/index.php | 39 +++++++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-article/update.php | 21 +++++++++++++++++++++ common/modules/blog/views/blog-article/view.php | 42 ++++++++++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-category/_form.php | 29 +++++++++++++++++++++++++++++ common/modules/blog/views/blog-category/_search.php | 35 +++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-category/create.php | 21 +++++++++++++++++++++ common/modules/blog/views/blog-category/index.php | 36 ++++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-category/update.php | 21 +++++++++++++++++++++ common/modules/blog/views/blog-category/view.php | 39 +++++++++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-tag/_form.php | 23 +++++++++++++++++++++++ common/modules/blog/views/blog-tag/_search.php | 27 +++++++++++++++++++++++++++ common/modules/blog/views/blog-tag/create.php | 21 +++++++++++++++++++++ common/modules/blog/views/blog-tag/index.php | 32 ++++++++++++++++++++++++++++++++ common/modules/blog/views/blog-tag/update.php | 21 +++++++++++++++++++++ common/modules/blog/views/blog-tag/view.php | 35 +++++++++++++++++++++++++++++++++++ common/modules/blog/views/default/index.php | 12 ++++++++++++ console/migrations/blog/m161101_142334_blog_article.php | 31 +++++++++++++++++++++++++++++++ console/migrations/blog/m161101_142752_blog_article_lang.php | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/blog/m161101_143033_blog_category.php | 29 +++++++++++++++++++++++++++++ console/migrations/blog/m161101_143259_blog_category_lang.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/blog/m161101_143541_blog_article_to_category.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/blog/m161101_143734_blog_tag.php | 24 ++++++++++++++++++++++++ console/migrations/blog/m161101_143939_blog_tag_lang.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/blog/m161101_144140_blog_article_to_tag.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/blog/m161101_144312_blog_article_to_article.php | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/blog/m161101_144434_blog_article_to_product.php | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/m161031_160156_blog.php | 43 ------------------------------------------- frontend/config/test-local.php | 0 standards | 0 51 files changed, 2446 insertions(+), 43 deletions(-) mode change 100644 => 100755 backend/config/test-local.php mode change 100644 => 100755 backup_leha.sql mode change 100644 => 100755 common/config/test-local.php create mode 100644 common/modules/blog/Module.php create mode 100644 common/modules/blog/controllers/BlogArticleController.php create mode 100644 common/modules/blog/controllers/BlogCategoryController.php create mode 100644 common/modules/blog/controllers/BlogTagController.php create mode 100644 common/modules/blog/controllers/DefaultController.php create mode 100644 common/modules/blog/models/BlogArticle.php create mode 100644 common/modules/blog/models/BlogArticleLang.php create mode 100644 common/modules/blog/models/BlogArticleSearch.php create mode 100644 common/modules/blog/models/BlogCategory.php create mode 100644 common/modules/blog/models/BlogCategoryLang.php create mode 100644 common/modules/blog/models/BlogCategorySearch.php create mode 100644 common/modules/blog/models/BlogTag.php create mode 100644 common/modules/blog/models/BlogTagLang.php create mode 100644 common/modules/blog/models/BlogTagSearch.php create mode 100644 common/modules/blog/views/blog-article/_form.php create mode 100644 common/modules/blog/views/blog-article/_search.php create mode 100644 common/modules/blog/views/blog-article/create.php create mode 100644 common/modules/blog/views/blog-article/index.php create mode 100644 common/modules/blog/views/blog-article/update.php create mode 100644 common/modules/blog/views/blog-article/view.php create mode 100644 common/modules/blog/views/blog-category/_form.php create mode 100644 common/modules/blog/views/blog-category/_search.php create mode 100644 common/modules/blog/views/blog-category/create.php create mode 100644 common/modules/blog/views/blog-category/index.php create mode 100644 common/modules/blog/views/blog-category/update.php create mode 100644 common/modules/blog/views/blog-category/view.php create mode 100644 common/modules/blog/views/blog-tag/_form.php create mode 100644 common/modules/blog/views/blog-tag/_search.php create mode 100644 common/modules/blog/views/blog-tag/create.php create mode 100644 common/modules/blog/views/blog-tag/index.php create mode 100644 common/modules/blog/views/blog-tag/update.php create mode 100644 common/modules/blog/views/blog-tag/view.php create mode 100644 common/modules/blog/views/default/index.php create mode 100755 console/migrations/blog/m161101_142334_blog_article.php create mode 100755 console/migrations/blog/m161101_142752_blog_article_lang.php create mode 100755 console/migrations/blog/m161101_143033_blog_category.php create mode 100755 console/migrations/blog/m161101_143259_blog_category_lang.php create mode 100755 console/migrations/blog/m161101_143541_blog_article_to_category.php create mode 100755 console/migrations/blog/m161101_143734_blog_tag.php create mode 100755 console/migrations/blog/m161101_143939_blog_tag_lang.php create mode 100755 console/migrations/blog/m161101_144140_blog_article_to_tag.php create mode 100755 console/migrations/blog/m161101_144312_blog_article_to_article.php create mode 100755 console/migrations/blog/m161101_144434_blog_article_to_product.php delete mode 100644 console/migrations/m161031_160156_blog.php mode change 100644 => 100755 frontend/config/test-local.php mode change 100644 => 100755 standards diff --git a/backend/config/test-local.php b/backend/config/test-local.php old mode 100644 new mode 100755 index 4513a34..4513a34 --- a/backend/config/test-local.php +++ b/backend/config/test-local.php diff --git a/backend/views/layouts/main-sidebar.php b/backend/views/layouts/main-sidebar.php index 15e30c7..0bb4414 100755 --- a/backend/views/layouts/main-sidebar.php +++ b/backend/views/layouts/main-sidebar.php @@ -121,6 +121,29 @@ use yii\widgets\Menu; 'options' => ['class'=>\Yii::$app->user->can('article') ? '' :'hide'], ], [ + 'label' => 'Блог', + 'template'=>' {label}', + 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'], + 'active' => preg_match('/^blog.*$/', $this->context->id) ? true : false, + 'items' => [ + [ + 'label' => 'Статьи', + 'url' => ['/blog/blog-article'], + 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'], + ], + [ + 'label' => 'Рубрики', + 'url' => ['/blog/blog-category'], + 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'], + ], + [ + 'label' => 'Тэги', + 'url' => ['/blog/blog-tag'], + 'options' => ['class'=>\Yii::$app->user->can('blog') ? '' :'hide'], + ], + ] + ], + [ 'label' => 'Акции', 'template'=>' {label}', 'url' => ['/event/index'], diff --git a/backup_leha.sql b/backup_leha.sql old mode 100644 new mode 100755 index 503d395..503d395 --- a/backup_leha.sql +++ b/backup_leha.sql diff --git a/common/config/main.php b/common/config/main.php index e608240..a420928 100755 --- a/common/config/main.php +++ b/common/config/main.php @@ -53,5 +53,8 @@ 'artbox-comment' => [ 'class' => 'common\modules\comment\Module', ], + 'blog' => [ + 'class' => 'common\modules\blog\Module' + ], ], ]; diff --git a/common/config/test-local.php b/common/config/test-local.php old mode 100644 new mode 100755 index b30e64b..b30e64b --- a/common/config/test-local.php +++ b/common/config/test-local.php diff --git a/common/modules/blog/Module.php b/common/modules/blog/Module.php new file mode 100644 index 0000000..cd85726 --- /dev/null +++ b/common/modules/blog/Module.php @@ -0,0 +1,24 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all BlogArticle models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BlogArticleSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single BlogArticle model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new BlogArticle model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new BlogArticle(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing BlogArticle model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing BlogArticle model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the BlogArticle model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return BlogArticle the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = BlogArticle::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/common/modules/blog/controllers/BlogCategoryController.php b/common/modules/blog/controllers/BlogCategoryController.php new file mode 100644 index 0000000..c1cddee --- /dev/null +++ b/common/modules/blog/controllers/BlogCategoryController.php @@ -0,0 +1,124 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all BlogCategory models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BlogCategorySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single BlogCategory model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new BlogCategory model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new BlogCategory(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing BlogCategory model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing BlogCategory model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the BlogCategory model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return BlogCategory the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = BlogCategory::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/common/modules/blog/controllers/BlogTagController.php b/common/modules/blog/controllers/BlogTagController.php new file mode 100644 index 0000000..48020a0 --- /dev/null +++ b/common/modules/blog/controllers/BlogTagController.php @@ -0,0 +1,124 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all BlogTag models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BlogTagSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single BlogTag model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new BlogTag model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new BlogTag(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing BlogTag model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing BlogTag model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the BlogTag model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return BlogTag the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = BlogTag::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/common/modules/blog/controllers/DefaultController.php b/common/modules/blog/controllers/DefaultController.php new file mode 100644 index 0000000..7cad6b8 --- /dev/null +++ b/common/modules/blog/controllers/DefaultController.php @@ -0,0 +1,20 @@ +render('index'); + } +} diff --git a/common/modules/blog/models/BlogArticle.php b/common/modules/blog/models/BlogArticle.php new file mode 100644 index 0000000..4a5b2be --- /dev/null +++ b/common/modules/blog/models/BlogArticle.php @@ -0,0 +1,196 @@ + [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'created_at', + 'updated_at', + 'deleted_at', + 'sort', + 'author_id', + ], + 'integer', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'image' ], + 'string', + 'max' => 255, + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'image' => 'Image', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + 'deleted_at' => 'Deleted At', + 'sort' => 'Sort', + 'status' => 'Status', + 'author_id' => 'Author ID', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticleLangs() + { + return $this->hasMany(BlogArticleLang::className(), [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguages() + { + return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) + ->viaTable('blog_article_lang', [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticleToArticles() + { + return $this->hasMany(BlogArticleToArticle::className(), [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticleToArticles0() + { + return $this->hasMany(BlogArticleToArticle::className(), [ 'related_blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRelatedBlogArticles() + { + return $this->hasMany(BlogArticle::className(), [ 'id' => 'related_blog_article_id' ]) + ->viaTable('blog_article_to_article', [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticles() + { + return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) + ->viaTable('blog_article_to_article', [ 'related_blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticleToCategories() + { + return $this->hasMany(BlogArticleToCategory::className(), [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogCategories() + { + return $this->hasMany(BlogCategory::className(), [ 'id' => 'blog_category_id' ]) + ->viaTable('blog_article_to_category', [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticleToProducts() + { + return $this->hasMany(BlogArticleToProduct::className(), [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProducts() + { + return $this->hasMany(Product::className(), [ 'id' => 'product_id' ]) + ->viaTable('blog_article_to_product', [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticleToTags() + { + return $this->hasMany(BlogArticleToTag::className(), [ 'blog_article_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogTags() + { + return $this->hasMany(BlogTag::className(), [ 'id' => 'blog_tag_id' ]) + ->viaTable('blog_article_to_tag', [ 'blog_article_id' => 'id' ]); + } + } diff --git a/common/modules/blog/models/BlogArticleLang.php b/common/modules/blog/models/BlogArticleLang.php new file mode 100644 index 0000000..f366f0e --- /dev/null +++ b/common/modules/blog/models/BlogArticleLang.php @@ -0,0 +1,88 @@ + 255], + [['alias'], 'unique'], + [['blog_article_id', 'language_id'], 'unique', 'targetAttribute' => ['blog_article_id', 'language_id'], 'message' => 'The combination of Blog Article ID and Language ID has already been taken.'], + [['blog_article_id'], 'exist', 'skipOnError' => true, 'targetClass' => BlogArticle::className(), 'targetAttribute' => ['blog_article_id' => 'id']], + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'blog_article_id' => 'Blog Article ID', + 'language_id' => 'Language ID', + 'title' => 'Title', + 'body' => 'Body', + 'body_preview' => 'Body Preview', + 'alias' => 'Alias', + 'meta_title' => 'Meta Title', + 'meta_description' => 'Meta Description', + 'h1' => 'H1', + 'seo_text' => 'Seo Text', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticle() + { + return $this->hasOne(BlogArticle::className(), ['id' => 'blog_article_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), ['id' => 'language_id']); + } +} diff --git a/common/modules/blog/models/BlogArticleSearch.php b/common/modules/blog/models/BlogArticleSearch.php new file mode 100644 index 0000000..1cb352e --- /dev/null +++ b/common/modules/blog/models/BlogArticleSearch.php @@ -0,0 +1,84 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + 'deleted_at' => $this->deleted_at, + 'sort' => $this->sort, + 'status' => $this->status, + 'author_id' => $this->author_id, + ]); + + $query->andFilterWhere(['like', 'image', $this->image]); + + return $dataProvider; + } +} diff --git a/common/modules/blog/models/BlogCategory.php b/common/modules/blog/models/BlogCategory.php new file mode 100644 index 0000000..7b2dfa1 --- /dev/null +++ b/common/modules/blog/models/BlogCategory.php @@ -0,0 +1,115 @@ + [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'sort', + 'parent_id', + ], + 'integer', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'image' ], + 'string', + 'max' => 255, + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'sort' => 'Sort', + 'image' => 'Image', + 'parent_id' => 'Parent ID', + 'status' => 'Status', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticleToCategories() + { + return $this->hasMany(BlogArticleToCategory::className(), [ 'blog_category_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticles() + { + return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) + ->viaTable('blog_article_to_category', [ 'blog_category_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogCategoryLangs() + { + return $this->hasMany(BlogCategoryLang::className(), [ 'blog_category_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguages() + { + return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) + ->viaTable('blog_category_lang', [ 'blog_category_id' => 'id' ]); + } + } diff --git a/common/modules/blog/models/BlogCategoryLang.php b/common/modules/blog/models/BlogCategoryLang.php new file mode 100644 index 0000000..0bf559a --- /dev/null +++ b/common/modules/blog/models/BlogCategoryLang.php @@ -0,0 +1,85 @@ + 255], + [['alias'], 'unique'], + [['blog_category_id', 'language_id'], 'unique', 'targetAttribute' => ['blog_category_id', 'language_id'], 'message' => 'The combination of Blog Category ID and Language ID has already been taken.'], + [['blog_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => BlogCategory::className(), 'targetAttribute' => ['blog_category_id' => 'id']], + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'blog_category_id' => 'Blog Category ID', + 'language_id' => 'Language ID', + 'title' => 'Title', + 'alias' => 'Alias', + 'description' => 'Description', + 'meta_title' => 'Meta Title', + 'meta_description' => 'Meta Description', + 'h1' => 'H1', + 'seo_text' => 'Seo Text', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogCategory() + { + return $this->hasOne(BlogCategory::className(), ['id' => 'blog_category_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), ['id' => 'language_id']); + } +} diff --git a/common/modules/blog/models/BlogCategorySearch.php b/common/modules/blog/models/BlogCategorySearch.php new file mode 100644 index 0000000..a674c7a --- /dev/null +++ b/common/modules/blog/models/BlogCategorySearch.php @@ -0,0 +1,81 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'sort' => $this->sort, + 'parent_id' => $this->parent_id, + 'status' => $this->status, + ]); + + $query->andFilterWhere(['like', 'image', $this->image]); + + return $dataProvider; + } +} diff --git a/common/modules/blog/models/BlogTag.php b/common/modules/blog/models/BlogTag.php new file mode 100644 index 0000000..6a3a0be --- /dev/null +++ b/common/modules/blog/models/BlogTag.php @@ -0,0 +1,95 @@ + [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'id' ], + 'integer', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticleToTags() + { + return $this->hasMany(BlogArticleToTag::className(), [ 'blog_tag_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogArticles() + { + return $this->hasMany(BlogArticle::className(), [ 'id' => 'blog_article_id' ]) + ->viaTable('blog_article_to_tag', [ 'blog_tag_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogTagLangs() + { + return $this->hasMany(BlogTagLang::className(), [ 'blog_tag_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguages() + { + return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) + ->viaTable('blog_tag_lang', [ 'blog_tag_id' => 'id' ]); + } + } diff --git a/common/modules/blog/models/BlogTagLang.php b/common/modules/blog/models/BlogTagLang.php new file mode 100644 index 0000000..26de932 --- /dev/null +++ b/common/modules/blog/models/BlogTagLang.php @@ -0,0 +1,71 @@ + 255], + [['blog_tag_id', 'language_id'], 'unique', 'targetAttribute' => ['blog_tag_id', 'language_id'], 'message' => 'The combination of Blog Tag ID and Language ID has already been taken.'], + [['blog_tag_id'], 'exist', 'skipOnError' => true, 'targetClass' => BlogTag::className(), 'targetAttribute' => ['blog_tag_id' => 'id']], + [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'blog_tag_id' => 'Blog Tag ID', + 'language_id' => 'Language ID', + 'label' => 'Label', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBlogTag() + { + return $this->hasOne(BlogTag::className(), ['id' => 'blog_tag_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), ['id' => 'language_id']); + } +} diff --git a/common/modules/blog/models/BlogTagSearch.php b/common/modules/blog/models/BlogTagSearch.php new file mode 100644 index 0000000..1380599 --- /dev/null +++ b/common/modules/blog/models/BlogTagSearch.php @@ -0,0 +1,74 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + ]); + + return $dataProvider; + } +} diff --git a/common/modules/blog/views/blog-article/_form.php b/common/modules/blog/views/blog-article/_form.php new file mode 100644 index 0000000..31fce7b --- /dev/null +++ b/common/modules/blog/views/blog-article/_form.php @@ -0,0 +1,35 @@ + + +
+ + + + field($model, 'image')->textInput(['maxlength' => true]) ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + + field($model, 'deleted_at')->textInput() ?> + + field($model, 'sort')->textInput() ?> + + field($model, 'status')->checkbox() ?> + + field($model, 'author_id')->textInput() ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/common/modules/blog/views/blog-article/_search.php b/common/modules/blog/views/blog-article/_search.php new file mode 100644 index 0000000..b644a88 --- /dev/null +++ b/common/modules/blog/views/blog-article/_search.php @@ -0,0 +1,41 @@ + + +
+ + ['index'], + 'method' => 'get', + ]); ?> + + field($model, 'id') ?> + + field($model, 'image') ?> + + field($model, 'created_at') ?> + + field($model, 'updated_at') ?> + + field($model, 'deleted_at') ?> + + field($model, 'sort') ?> + + field($model, 'status')->checkbox() ?> + + field($model, 'author_id') ?> + +
+ 'btn btn-primary']) ?> + 'btn btn-default']) ?> +
+ + + +
diff --git a/common/modules/blog/views/blog-article/create.php b/common/modules/blog/views/blog-article/create.php new file mode 100644 index 0000000..a1daa8b --- /dev/null +++ b/common/modules/blog/views/blog-article/create.php @@ -0,0 +1,21 @@ +title = 'Create Blog Article'; +$this->params['breadcrumbs'][] = ['label' => 'Blog Articles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/common/modules/blog/views/blog-article/index.php b/common/modules/blog/views/blog-article/index.php new file mode 100644 index 0000000..b86118b --- /dev/null +++ b/common/modules/blog/views/blog-article/index.php @@ -0,0 +1,39 @@ +title = 'Blog Articles'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'image', + 'created_at', + 'updated_at', + 'deleted_at', + // 'sort', + // 'status:boolean', + // 'author_id', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/common/modules/blog/views/blog-article/update.php b/common/modules/blog/views/blog-article/update.php new file mode 100644 index 0000000..bc50d0e --- /dev/null +++ b/common/modules/blog/views/blog-article/update.php @@ -0,0 +1,21 @@ +title = 'Update Blog Article: ' . $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Blog Articles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/common/modules/blog/views/blog-article/view.php b/common/modules/blog/views/blog-article/view.php new file mode 100644 index 0000000..3433737 --- /dev/null +++ b/common/modules/blog/views/blog-article/view.php @@ -0,0 +1,42 @@ +title = $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Blog Articles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'image', + 'created_at', + 'updated_at', + 'deleted_at', + 'sort', + 'status:boolean', + 'author_id', + ], + ]) ?> + +
diff --git a/common/modules/blog/views/blog-category/_form.php b/common/modules/blog/views/blog-category/_form.php new file mode 100644 index 0000000..7d39dc4 --- /dev/null +++ b/common/modules/blog/views/blog-category/_form.php @@ -0,0 +1,29 @@ + + +
+ + + + field($model, 'sort')->textInput() ?> + + field($model, 'image')->textInput(['maxlength' => true]) ?> + + field($model, 'parent_id')->textInput() ?> + + field($model, 'status')->checkbox() ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/common/modules/blog/views/blog-category/_search.php b/common/modules/blog/views/blog-category/_search.php new file mode 100644 index 0000000..b79d09d --- /dev/null +++ b/common/modules/blog/views/blog-category/_search.php @@ -0,0 +1,35 @@ + + + diff --git a/common/modules/blog/views/blog-category/create.php b/common/modules/blog/views/blog-category/create.php new file mode 100644 index 0000000..7aaa171 --- /dev/null +++ b/common/modules/blog/views/blog-category/create.php @@ -0,0 +1,21 @@ +title = 'Create Blog Category'; +$this->params['breadcrumbs'][] = ['label' => 'Blog Categories', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/common/modules/blog/views/blog-category/index.php b/common/modules/blog/views/blog-category/index.php new file mode 100644 index 0000000..35009ba --- /dev/null +++ b/common/modules/blog/views/blog-category/index.php @@ -0,0 +1,36 @@ +title = 'Blog Categories'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'sort', + 'image', + 'parent_id', + 'status:boolean', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/common/modules/blog/views/blog-category/update.php b/common/modules/blog/views/blog-category/update.php new file mode 100644 index 0000000..517b140 --- /dev/null +++ b/common/modules/blog/views/blog-category/update.php @@ -0,0 +1,21 @@ +title = 'Update Blog Category: ' . $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Blog Categories', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/common/modules/blog/views/blog-category/view.php b/common/modules/blog/views/blog-category/view.php new file mode 100644 index 0000000..512bb4c --- /dev/null +++ b/common/modules/blog/views/blog-category/view.php @@ -0,0 +1,39 @@ +title = $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Blog Categories', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'sort', + 'image', + 'parent_id', + 'status:boolean', + ], + ]) ?> + +
diff --git a/common/modules/blog/views/blog-tag/_form.php b/common/modules/blog/views/blog-tag/_form.php new file mode 100644 index 0000000..0fde157 --- /dev/null +++ b/common/modules/blog/views/blog-tag/_form.php @@ -0,0 +1,23 @@ + + +
+ + + + field($model, 'id')->textInput() ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/common/modules/blog/views/blog-tag/_search.php b/common/modules/blog/views/blog-tag/_search.php new file mode 100644 index 0000000..32b4064 --- /dev/null +++ b/common/modules/blog/views/blog-tag/_search.php @@ -0,0 +1,27 @@ + + + diff --git a/common/modules/blog/views/blog-tag/create.php b/common/modules/blog/views/blog-tag/create.php new file mode 100644 index 0000000..d6ef692 --- /dev/null +++ b/common/modules/blog/views/blog-tag/create.php @@ -0,0 +1,21 @@ +title = 'Create Blog Tag'; +$this->params['breadcrumbs'][] = ['label' => 'Blog Tags', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/common/modules/blog/views/blog-tag/index.php b/common/modules/blog/views/blog-tag/index.php new file mode 100644 index 0000000..8ebb5c6 --- /dev/null +++ b/common/modules/blog/views/blog-tag/index.php @@ -0,0 +1,32 @@ +title = 'Blog Tags'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/common/modules/blog/views/blog-tag/update.php b/common/modules/blog/views/blog-tag/update.php new file mode 100644 index 0000000..a327332 --- /dev/null +++ b/common/modules/blog/views/blog-tag/update.php @@ -0,0 +1,21 @@ +title = 'Update Blog Tag: ' . $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Blog Tags', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/common/modules/blog/views/blog-tag/view.php b/common/modules/blog/views/blog-tag/view.php new file mode 100644 index 0000000..28c02c8 --- /dev/null +++ b/common/modules/blog/views/blog-tag/view.php @@ -0,0 +1,35 @@ +title = $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Blog Tags', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + ], + ]) ?> + +
diff --git a/common/modules/blog/views/default/index.php b/common/modules/blog/views/default/index.php new file mode 100644 index 0000000..650b9c5 --- /dev/null +++ b/common/modules/blog/views/default/index.php @@ -0,0 +1,12 @@ +
+

context->action->uniqueId ?>

+

+ This is the view content for action "context->action->id ?>". + The action belongs to the controller "context) ?>" + in the "context->module->id ?>" module. +

+

+ You may customize this page by editing the following file:
+ +

+
diff --git a/console/migrations/blog/m161101_142334_blog_article.php b/console/migrations/blog/m161101_142334_blog_article.php new file mode 100755 index 0000000..235e2cb --- /dev/null +++ b/console/migrations/blog/m161101_142334_blog_article.php @@ -0,0 +1,31 @@ +createTable( + 'blog_article', + [ + 'id' => $this->primaryKey(), + 'image' => $this->string(255), + 'created_at' => $this->integer(), + 'updated_at' => $this->integer(), + 'deleted_at' => $this->integer(), + 'sort' => $this->integer(), + 'status' => $this->boolean(), + 'author_id' => $this->integer(), + ] + ); + } + + public function down() + { + $this->dropTable('blog_article'); + } +} diff --git a/console/migrations/blog/m161101_142752_blog_article_lang.php b/console/migrations/blog/m161101_142752_blog_article_lang.php new file mode 100755 index 0000000..2fabca7 --- /dev/null +++ b/console/migrations/blog/m161101_142752_blog_article_lang.php @@ -0,0 +1,83 @@ +createTable( + 'blog_article_lang', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'language_id' => $this->integer() + ->notNull(), + 'title' => $this->string(255), + 'body' => $this->text(), + 'body_preview' => $this->text(), + 'alias' => $this->string(255), + 'meta_title' => $this->string(255), + 'meta_description' => $this->string(255), + 'h1' => $this->string(255), + 'seo_text' => $this->string(255), + ] + ); + + /** + * Creating indexes for unique fields (field pairs) + */ + $this->createIndex( + 'blog_article_lang_uk', + 'blog_article_lang', + [ + 'blog_article_id', + 'language_id', + ], + true + ); + + $this->createIndex( + 'blog_article_alias_uk', + 'blog_article_lang', + 'alias', + true + ); + + /** + * Add foreign keys in blog_articles and language tables + */ + $this->addForeignKey( + 'blog_article_fk', + 'blog_article_lang', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_lang_fk', + 'blog_article_lang', + 'language_id', + 'language', + 'id', + 'RESTRICT', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_lang_fk', 'blog_article_lang'); + $this->dropForeignKey('blog_article_fk', 'blog_article_lang'); + $this->dropIndex('blog_article_alias_uk', 'blog_article_lang'); + $this->dropIndex('blog_article_lang_uk', 'blog_article_lang'); + $this->dropTable('blog_article_lang'); + } +} diff --git a/console/migrations/blog/m161101_143033_blog_category.php b/console/migrations/blog/m161101_143033_blog_category.php new file mode 100755 index 0000000..e2bfe5f --- /dev/null +++ b/console/migrations/blog/m161101_143033_blog_category.php @@ -0,0 +1,29 @@ +createTable( + 'blog_category', + [ + 'id' => $this->primaryKey(), + 'sort' => $this->integer(), + 'image' => $this->string(255), + 'parent_id' => $this->integer() + ->defaultValue(0), + 'status' => $this->boolean(), + ] + ); + } + + public function down() + { + $this->dropTable('blog_category'); + } +} diff --git a/console/migrations/blog/m161101_143259_blog_category_lang.php b/console/migrations/blog/m161101_143259_blog_category_lang.php new file mode 100755 index 0000000..72f2e14 --- /dev/null +++ b/console/migrations/blog/m161101_143259_blog_category_lang.php @@ -0,0 +1,82 @@ +createTable( + 'blog_category_lang', + [ + 'id' => $this->primaryKey(), + 'blog_category_id' => $this->integer() + ->notNull(), + 'language_id' => $this->integer() + ->notNull(), + 'title' => $this->string(255), + 'alias' => $this->string(255), + 'description' => $this->text(), + 'meta_title' => $this->string(255), + 'meta_description' => $this->string(255), + 'h1' => $this->string(255), + 'seo_text' => $this->string(255), + ] + ); + + /** + * Create unique indexes for language and alias + */ + $this->createIndex( + 'blog_category_lang_uk', + 'blog_category_lang', + [ + 'blog_category_id', + 'language_id', + ], + true + ); + + $this->createIndex( + 'blog_category_alias_uk', + 'blog_category_lang', + 'alias', + true + ); + + /** + * Add foreign keys for language tables + */ + $this->addForeignKey( + 'blog_category_fk', + 'blog_category_lang', + 'blog_category_id', + 'blog_category', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_category_lang_fk', + 'blog_category_lang', + 'language_id', + 'language', + 'id', + 'RESTRICT', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_category_lang_fk', 'blog_category_lang'); + $this->dropForeignKey('blog_category_fk', 'blog_category_lang'); + $this->dropIndex('blog_category_alias_uk', 'blog_category_lang'); + $this->dropIndex('blog_category_lang_uk', 'blog_category_lang'); + $this->dropTable('blog_category_lang'); + } +} diff --git a/console/migrations/blog/m161101_143541_blog_article_to_category.php b/console/migrations/blog/m161101_143541_blog_article_to_category.php new file mode 100755 index 0000000..fd21784 --- /dev/null +++ b/console/migrations/blog/m161101_143541_blog_article_to_category.php @@ -0,0 +1,64 @@ +createTable( + 'blog_article_to_category', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'blog_category_id' => $this->integer() + ->notNull(), + ] + ); + + /** + * Add foreign keys and indexes for junction table + */ + $this->createIndex( + 'blog_article_to_category_uk', + 'blog_article_to_category', + [ + 'blog_article_id', + 'blog_category_id', + ], + true + ); + + $this->addForeignKey( + 'blog_article_to_category_art_fk', + 'blog_article_to_category', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_to_category_cat_fk', + 'blog_article_to_category', + 'blog_category_id', + 'blog_category', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_to_category_cat_fk', 'blog_article_to_category'); + $this->dropForeignKey('blog_article_to_category_art_fk', 'blog_article_to_category'); + $this->dropIndex('blog_article_to_category_uk', 'blog_article_to_category'); + $this->dropTable('blog_article_to_category'); + } +} diff --git a/console/migrations/blog/m161101_143734_blog_tag.php b/console/migrations/blog/m161101_143734_blog_tag.php new file mode 100755 index 0000000..292ee38 --- /dev/null +++ b/console/migrations/blog/m161101_143734_blog_tag.php @@ -0,0 +1,24 @@ +createTable( + 'blog_tag', + [ + 'id' => $this->primaryKey(), + ] + ); + } + + public function down() + { + $this->dropTable('blog_tag'); + } +} diff --git a/console/migrations/blog/m161101_143939_blog_tag_lang.php b/console/migrations/blog/m161101_143939_blog_tag_lang.php new file mode 100755 index 0000000..a98a4d5 --- /dev/null +++ b/console/migrations/blog/m161101_143939_blog_tag_lang.php @@ -0,0 +1,65 @@ +createTable( + 'blog_tag_lang', + [ + 'id' => $this->primaryKey(), + 'blog_tag_id' => $this->integer() + ->notNull(), + 'language_id' => $this->integer() + ->notNull(), + 'label' => $this->string(255), + ] + ); + + /** + * Creating indexes and foreign keys for language table + */ + $this->createIndex( + 'blog_tag_lang_uk', + 'blog_tag_lang', + [ + 'blog_tag_id', + 'language_id', + ], + true + ); + + $this->addForeignKey( + 'blog_tag_lang_fk', + 'blog_tag_lang', + 'language_id', + 'language', + 'id', + 'RESTRICT', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_tag_fk', + 'blog_tag_lang', + 'blog_tag_id', + 'blog_tag', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_tag_fk', 'blog_tag_lang'); + $this->dropForeignKey('blog_tag_lang_fk', 'blog_tag_lang'); + $this->dropIndex('blog_tag_lang_uk', 'blog_tag_lang'); + $this->dropTable('blog_tag_lang'); + } +} diff --git a/console/migrations/blog/m161101_144140_blog_article_to_tag.php b/console/migrations/blog/m161101_144140_blog_article_to_tag.php new file mode 100755 index 0000000..aed42ad --- /dev/null +++ b/console/migrations/blog/m161101_144140_blog_article_to_tag.php @@ -0,0 +1,64 @@ +createTable( + 'blog_article_to_tag', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'blog_tag_id' => $this->integer() + ->notNull(), + ] + ); + + /** + * Create indexes and foreign keys for junction table + */ + $this->createIndex( + 'blog_article_to_tag_uk', + 'blog_article_to_tag', + [ + 'blog_article_id', + 'blog_tag_id', + ], + true + ); + + $this->addForeignKey( + 'blog_article_to_tag_tag_fk', + 'blog_article_to_tag', + 'blog_tag_id', + 'blog_tag', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_to_tag_art_fk', + 'blog_article_to_tag', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_to_tag_art_fk', 'blog_article_to_tag'); + $this->dropForeignKey('blog_article_to_tag_tag_fk', 'blog_article_to_tag'); + $this->dropIndex('blog_article_to_tag_uk', 'blog_article_to_tag'); + $this->dropTable('blog_article_to_tag'); + } +} diff --git a/console/migrations/blog/m161101_144312_blog_article_to_article.php b/console/migrations/blog/m161101_144312_blog_article_to_article.php new file mode 100755 index 0000000..a4f42b4 --- /dev/null +++ b/console/migrations/blog/m161101_144312_blog_article_to_article.php @@ -0,0 +1,61 @@ +createTable( + 'blog_article_to_article', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'related_blog_article_id' => $this->integer() + ->notNull(), + ] + ); + + $this->createIndex( + 'blog_article_to_article_uk', + 'blog_article_to_article', + [ + 'blog_article_id', + 'related_blog_article_id', + ], + true + ); + + $this->addForeignKey( + 'blog_article_to_article_art_fk', + 'blog_article_to_article', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_to_article_rel_fk', + 'blog_article_to_article', + 'related_blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_to_article_rel_fk', 'blog_article_to_article'); + $this->dropForeignKey('blog_article_to_article_art_fk', 'blog_article_to_article'); + $this->dropIndex('blog_article_to_article_uk', 'blog_article_to_article'); + $this->dropTable('blog_article_to_article'); + } +} diff --git a/console/migrations/blog/m161101_144434_blog_article_to_product.php b/console/migrations/blog/m161101_144434_blog_article_to_product.php new file mode 100755 index 0000000..a47bc41 --- /dev/null +++ b/console/migrations/blog/m161101_144434_blog_article_to_product.php @@ -0,0 +1,61 @@ +createTable( + 'blog_article_to_product', + [ + 'id' => $this->primaryKey(), + 'blog_article_id' => $this->integer() + ->notNull(), + 'product_id' => $this->integer() + ->notNull(), + ] + ); + + $this->createIndex( + 'blog_article_to_product_uk', + 'blog_article_to_product', + [ + 'blog_article_id', + 'product_id', + ], + true + ); + + $this->addForeignKey( + 'blog_article_to_product_art_fk', + 'blog_article_to_product', + 'blog_article_id', + 'blog_article', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'blog_article_to_product_prod_fk', + 'blog_article_to_product', + 'product_id', + 'product', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function down() + { + $this->dropForeignKey('blog_article_to_product_prod_fk', 'blog_article_to_product'); + $this->dropForeignKey('blog_article_to_product_art_fk', 'blog_article_to_product'); + $this->dropIndex('blog_article_to_product_uk', 'blog_article_to_product'); + $this->dropTable('blog_article_to_product'); + } +} diff --git a/console/migrations/m161031_160156_blog.php b/console/migrations/m161031_160156_blog.php deleted file mode 100644 index 6a30e7e..0000000 --- a/console/migrations/m161031_160156_blog.php +++ /dev/null @@ -1,43 +0,0 @@ -createTable( - 'blog_article', - [ - 'id' => $this->primaryKey(), - 'image' => $this->string(255), - 'created_at' => $this->integer(), - 'updated_at' => $this->integer(), - 'deleted_at' => $this->integer(), - 'sort' => $this->integer(), - 'status' => $this->boolean(), - 'author_id' => $this->integer(), - ] - ); - - $this->createTable( - 'blog_article_lang', - [ - 'title' => $this->string(255), - 'body' => $this->text(), - 'body_preview' => $this->text(), - 'alias' => $this->string(255), - 'meta_title' => $this->string(255), - 'meta_description' => $this->string(255), - 'h1' => $this->string(255), - 'seo_text' => $this->string(255), - ] - ); - } - - public function down() - { - - } - } diff --git a/frontend/config/test-local.php b/frontend/config/test-local.php old mode 100644 new mode 100755 index 4513a34..4513a34 --- a/frontend/config/test-local.php +++ b/frontend/config/test-local.php diff --git a/standards b/standards old mode 100644 new mode 100755 index 5c5650a..5c5650a --- a/standards +++ b/standards -- libgit2 0.21.4