diff --git a/common/models/Portfolio.php b/common/models/Portfolio.php index 2500d79..d708996 100644 --- a/common/models/Portfolio.php +++ b/common/models/Portfolio.php @@ -107,19 +107,20 @@ public function attributeLabels() { return [ - 'portfolio_id' => Yii::t('app', 'Portfolio ID'), - 'user_id' => Yii::t('app', 'User ID'), - 'name' => Yii::t('app', 'Название'), - 'link' => Yii::t('app', 'URL'), - 'date_add' => Yii::t('app', 'Дата добавления'), - 'user_add_id' => Yii::t('app', 'User Add ID'), - 'view_count' => Yii::t('app', 'Количество просмотров'), - 'city' => Yii::t('app', 'Город'), - 'street' => Yii::t('app', 'Улица'), - 'house' => Yii::t('app', 'Дом'), - 'description' => Yii::t('app', 'Описание'), - 'cover' => Yii::t('app', 'Фото главное'), - 'gallery_id' => Yii::t('app', 'Фото галерея'), + 'portfolio_id' => Yii::t('app', 'Portfolio ID'), + 'user_id' => Yii::t('app', 'User ID'), + 'name' => Yii::t('app', 'Название'), + 'link' => Yii::t('app', 'URL'), + 'date_add' => Yii::t('app', 'Дата добавления'), + 'user_add_id' => Yii::t('app', 'User Add ID'), + 'view_count' => Yii::t('app', 'Количество просмотров'), + 'city' => Yii::t('app', 'Город'), + 'street' => Yii::t('app', 'Улица'), + 'house' => Yii::t('app', 'Дом'), + 'description' => Yii::t('app', 'Описание'), + 'cover' => Yii::t('app', 'Фото главное'), + 'gallery_id' => Yii::t('app', 'Фото галерея'), + 'specializationString' => Yii::t('app', 'Специализации'), ]; } @@ -148,4 +149,21 @@ { $this->specializationInput = $value; } + + public function getSpecializationString() + { + return implode(', ', $this->getSpecializations() + ->select([ + 'specialization_name', + 'specialization_id', + ]) + ->asArray() + ->indexBy('specialization_id') + ->column()); + } + + public function setSpecializationString($value) + { + $this->specializationString = $value; + } } diff --git a/common/models/PortfolioSearch.php b/common/models/PortfolioSearch.php index b3b9c58..78061c8 100644 --- a/common/models/PortfolioSearch.php +++ b/common/models/PortfolioSearch.php @@ -1,80 +1,138 @@ $query, - ]); + // add conditions that should always apply here - $this->load($params); + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); - 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; - } + $this->load($params); - // grid filtering conditions - $query->andFilterWhere([ - 'portfolio_id' => $this->portfolio_id, - 'user_id' => $this->user_id, - 'date_add' => $this->date_add, - 'user_add_id' => $this->user_add_id, - 'view_count' => $this->view_count, - 'gallery_id' => $this->gallery_id, - ]); + 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; + } - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'link', $this->link]) - ->andFilterWhere(['like', 'city', $this->city]) - ->andFilterWhere(['like', 'street', $this->street]) - ->andFilterWhere(['like', 'house', $this->house]) - ->andFilterWhere(['like', 'description', $this->description]) - ->andFilterWhere(['like', 'cover', $this->cover]); + $query->joinWith('specializations'); - return $dataProvider; + // grid filtering conditions + $query->andFilterWhere([ + 'portfolio_id' => $this->portfolio_id, + 'user_id' => $this->user_id, + 'date_add' => $this->date_add, + 'user_add_id' => $this->user_add_id, + 'view_count' => $this->view_count, + 'gallery_id' => $this->gallery_id, + ]); + + $query->andFilterWhere([ + 'like', + 'name', + $this->name, + ]) + ->andFilterWhere([ + 'like', + 'link', + $this->link, + ]) + ->andFilterWhere([ + 'like', + 'city', + $this->city, + ]) + ->andFilterWhere([ + 'like', + 'street', + $this->street, + ]) + ->andFilterWhere([ + 'like', + 'house', + $this->house, + ]) + ->andFilterWhere([ + 'like', + 'description', + $this->description, + ]) + ->andFilterWhere([ + 'like', + 'cover', + $this->cover, + ]) + ->andFilterWhere([ + 'like', + 'specialization.specialization_name', + $this->specializationString, + ]); + + return $dataProvider; + } } -} diff --git a/common/models/Project.php b/common/models/Project.php index 799e510..263d363 100644 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -103,6 +103,11 @@ 'string', 'max' => 255, ], + [ + [ 'view_count' ], + 'default', + 'value' => 0, + ], ]; } @@ -132,6 +137,7 @@ 'file' => Yii::t('app', 'Присоединить файл'), 'specializationInput' => Yii::t('app', 'Специализации'), 'paymentInput' => Yii::t('app', 'Способ оплаты'), + 'specializationString' => Yii::t('app', 'Специализации'), ]; } @@ -186,4 +192,21 @@ { $this->paymentInput = $value; } + + public function getSpecializationString() + { + return implode(', ', $this->getSpecializations() + ->select([ + 'specialization_name', + 'specialization_id', + ]) + ->asArray() + ->indexBy('specialization_id') + ->column()); + } + + public function setSpecializationString($value) + { + $this->specializationString = $value; + } } diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 33b9bc5..72e6e0a 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -2,18 +2,22 @@ namespace frontend\controllers; use common\models\Blog; + use common\models\BlogSearch; use common\models\CompanyInfo; use common\models\Country; use common\models\Department; use common\models\Employment; use common\models\Fields; use common\models\Gallery; + use common\models\GallerySearch; use common\models\Job; use common\models\Language; use common\models\Payment; use common\models\Portfolio; + use common\models\PortfolioSearch; use common\models\PortfolioSpecialization; use common\models\Project; + use common\models\ProjectSearch; use common\models\Specialization; use common\models\Team; use common\models\TeamSearch; @@ -54,7 +58,11 @@ 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ - 'team-delete' => [ 'POST' ], + 'team-delete' => [ 'POST' ], + 'vacancy-delete' => [ 'POST' ], + 'portfolio-delete' => [ 'POST' ], + 'projects-delete' => [ 'POST' ], + 'blog-delete' => [ 'POST' ], ], ], ]; @@ -71,7 +79,13 @@ public function actionBlog() { - return $this->render('blog'); + $searchModel = new BlogSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('blog', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); } public function actionBlogCreate() @@ -81,7 +95,7 @@ if($blog->load($post) && $blog->save()) { return $this->redirect([ 'blog-update', - [ 'id' => $blog->blog_id ], + 'id' => $blog->blog_id, ]); } else { return $this->render('_blog_form', [ 'blog' => $blog ]); @@ -99,6 +113,13 @@ } } + public function actionBlogDelete($id) + { + Blog::findOne($id) + ->delete(); + $this->redirect('blog'); + } + public function actionBookmarks() { return $this->render('bookmarks'); @@ -208,7 +229,13 @@ public function actionGallery() { + $searchModel = new GallerySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + return $this->render('gallery', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); } public function actionGalleryCreate() @@ -289,7 +316,13 @@ public function actionPortfolio() { - return $this->render('portfolio'); + $searchModel = new PortfolioSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('portfolio', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); } public function actionPortfolioCreate() @@ -352,9 +385,22 @@ ]); } + public function actionPortfolioDelete($id) + { + Portfolio::findOne($id) + ->delete(); + $this->redirect('portfolio'); + } + public function actionProjects() { - return $this->render('projects'); + $searchModel = new ProjectSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('projects', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); } public function actionProjectsCreate() @@ -500,6 +546,13 @@ ]); } + public function actionProjectsDelete($id) + { + Project::findOne($id) + ->delete(); + $this->redirect('projects'); + } + public function actionService() { $user = \Yii::$app->user->identity; @@ -750,7 +803,7 @@ public function actionVacancyDelete($id) { Vacancy::findOne($id) - ->delete(); + ->delete(); $this->redirect('vacancy'); } diff --git a/frontend/controllers/ProjectsController.php b/frontend/controllers/ProjectsController.php new file mode 100644 index 0000000..50ab794 --- /dev/null +++ b/frontend/controllers/ProjectsController.php @@ -0,0 +1,29 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + //'actions' => ['cabinet','change-password', 'bookmarks', 'projects'], + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + ]; + } + + public function actionIndex() + { + return $this->render('projects'); + } + } \ No newline at end of file diff --git a/frontend/views/accounts/blog.php b/frontend/views/accounts/blog.php index 2e17d4e..41b75ed 100644 --- a/frontend/views/accounts/blog.php +++ b/frontend/views/accounts/blog.php @@ -1,10 +1,55 @@ title = 'Мой профиль'; - $this->params['breadcrumbs'][] = $this->title; + $this->title = 'Блог'; + $this->params[ 'breadcrumbs' ][] = $this->title; ?> -
+ = Html::a(Yii::t('app', 'Добавить'), [ 'blog-create' ], [ 'class' => 'btn btn-success' ]) ?> +
+= GridView::widget([ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + [ + 'attribute' => 'blog_id', + 'label' => 'ID', + ], + 'name', + 'date_add', + 'view_count', + [ + 'class' => ActionColumn::className(), + 'buttons' => [ + 'update' => function($url, $model, $key) { + return Html::a('Update', [ + 'blog-update', + 'id' => $model->blog_id, + ]); + }, + 'delete' => function($url, $model, $key) { + return Html::a('Delete', [ + 'blog-delete', + 'id' => $model->blog_id, + ], [ + 'title' => 'Удалить', + 'aria-label' => 'Удалить', + 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?', + 'data-method' => 'post', + 'data-pjax' => '0', + ]); + }, + ], + 'template' => '{update} {delete}', + ], + ], +]); ?> diff --git a/frontend/views/accounts/gallery.php b/frontend/views/accounts/gallery.php index 162a954..ed2c270 100755 --- a/frontend/views/accounts/gallery.php +++ b/frontend/views/accounts/gallery.php @@ -1,26 +1,47 @@ title = 'Мой профиль'; - $this->params['breadcrumbs'][] = $this->title; -?> - -+ = Html::a(Yii::t('app', 'Добавить'), [ 'gallery-create' ], [ 'class' => 'btn btn-success' ]) ?> +
+= GridView::widget([ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + [ + 'attribute' => 'gallery_id', + 'label' => 'ID', + ], + 'name', + 'date_add', + [ + 'attribute' => 'type', + 'value' => function($model, $key, $index, $column) { + switch($model->type) { + case 2: + return 'Видео'; + break; + default: + return 'Фото'; + break; + } + }, + 'label' => 'Фото или Видео', + 'filter' => [ + 1 => 'Фото', + 2 => 'Видео', + ] + ], + ], +]) ?> diff --git a/frontend/views/accounts/portfolio.php b/frontend/views/accounts/portfolio.php index 2ba8d5a..bc814e8 100755 --- a/frontend/views/accounts/portfolio.php +++ b/frontend/views/accounts/portfolio.php @@ -14,31 +14,35 @@ ?>- = Html::a(Yii::t('app', 'Добавить'), [ 'vacancy-create' ], [ 'class' => 'btn btn-success' ]) ?> + = Html::a(Yii::t('app', 'Добавить'), [ 'portfolio-create' ], [ 'class' => 'btn btn-success' ]) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ [ - 'attribute' => 'vacancy_id', + 'attribute' => 'portfolio_id', 'label' => 'ID', ], 'name', + 'date_add', 'view_count', [ + 'attribute' => 'specializationString', + ], + [ 'class' => ActionColumn::className(), 'buttons' => [ 'update' => function($url, $model, $key) { return Html::a('Update', [ - 'vacancy-update', - 'id' => $model->vacancy_id, + 'portfolio-update', + 'id' => $model->portfolio_id, ]); }, 'delete' => function($url, $model, $key) { return Html::a('Delete', [ - 'vacancy-delete', - 'id' => $model->vacancy_id, + 'portfolio-delete', + 'id' => $model->portfolio_id, ], [ 'title' => 'Удалить', 'aria-label' => 'Удалить', diff --git a/frontend/views/accounts/projects.php b/frontend/views/accounts/projects.php index 3f53000..033f8b7 100755 --- a/frontend/views/accounts/projects.php +++ b/frontend/views/accounts/projects.php @@ -1,241 +1,59 @@ title = 'Мой профиль'; -$this->params['breadcrumbs'][] = $this->title; + /** + * @var ProjectSearch $searchModel + * @var ActiveDataProvider $dataProvider + */ + use common\models\ProjectSearch; + use yii\data\ActiveDataProvider; + use yii\grid\ActionColumn; + use yii\grid\GridView; + use yii\helpers\Html; + + $this->title = 'Проекты'; + $this->params[ 'breadcrumbs' ][] = $this->title; ?> -На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
-P.S. Студиям прошу не беспокоить! Нужен специалист в команду
-На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
-P.S. Студиям прошу не беспокоить! Нужен специалист в команду
-На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
-P.S. Студиям прошу не беспокоить! Нужен специалист в команду
-На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
-P.S. Студиям прошу не беспокоить! Нужен специалист в команду
-На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
-P.S. Студиям прошу не беспокоить! Нужен специалист в команду
-+ = Html::a(Yii::t('app', 'Добавить'), [ 'projects-create' ], [ 'class' => 'btn btn-success' ]) ?> +
+= GridView::widget([ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + [ + 'attribute' => 'project_id', + 'label' => 'ID', + ], + 'name', + 'budget', + 'city', + [ + 'attribute' => 'specializationString', + ], + 'view_count', + [ + 'class' => ActionColumn::className(), + 'buttons' => [ + 'update' => function($url, $model, $key) { + return Html::a('Update', [ + 'projects-update', + 'id' => $model->project_id, + ]); + }, + 'delete' => function($url, $model, $key) { + return Html::a('Delete', [ + 'projects-delete', + 'id' => $model->project_id, + ], [ + 'title' => 'Удалить', + 'aria-label' => 'Удалить', + 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?', + 'data-method' => 'post', + 'data-pjax' => '0', + ]); + }, + ], + 'template' => '{update} {delete}', + ], + ], +]); ?> diff --git a/frontend/views/projects/projects.php b/frontend/views/projects/projects.php new file mode 100644 index 0000000..3f53000 --- /dev/null +++ b/frontend/views/projects/projects.php @@ -0,0 +1,241 @@ +title = 'Мой профиль'; +$this->params['breadcrumbs'][] = $this->title; +?> +На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
+P.S. Студиям прошу не беспокоить! Нужен специалист в команду
+На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
+P.S. Студиям прошу не беспокоить! Нужен специалист в команду
+На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
+P.S. Студиям прошу не беспокоить! Нужен специалист в команду
+На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
+P.S. Студиям прошу не беспокоить! Нужен специалист в команду
+На постоянные работы по созданию сайтов, в нашу команду требуется html-верстальщик. Оплата сдельная за проект. В отклике прошу написать свой Skype и почту. А так же 3 проекта с реализованной адаптивной версткой и 3 проекта мобильных сайтов.
+P.S. Студиям прошу не беспокоить! Нужен специалист в команду
+