diff --git a/frontend/config/main.php b/frontend/config/main.php index 81d2b38..9fbadf2 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -60,4 +60,4 @@ return [ ], 'params' => $params, -]; +]; \ No newline at end of file diff --git a/frontend/modules/access/views/access/index.php b/frontend/modules/access/views/access/index.php index 326a232..4340a7c 100644 --- a/frontend/modules/access/views/access/index.php +++ b/frontend/modules/access/views/access/index.php @@ -2,6 +2,8 @@ use yii\grid\GridView; +$this->title = 'Доступы'; + echo GridView::widget([ 'dataProvider' => $dataProvider, 'columns' => [ diff --git a/frontend/modules/card/controllers/UserCardController.php b/frontend/modules/card/controllers/UserCardController.php index 271ece2..02e3d8b 100644 --- a/frontend/modules/card/controllers/UserCardController.php +++ b/frontend/modules/card/controllers/UserCardController.php @@ -3,11 +3,10 @@ namespace frontend\modules\card\controllers; -use common\classes\Debug; use common\models\CardSkill; use common\models\FieldsValueNew; use Yii; -use common\models\UserCard; +use frontend\modules\card\models\UserCard; use yii\data\ActiveDataProvider; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -26,7 +25,7 @@ class UserCardController extends Controller $id_user = Yii::$app->user->id; $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); - if($result){ + if($result) { $id = $result[0]['id']; $dataProvider = new ActiveDataProvider([ 'query' => FieldsValueNew::find() @@ -49,6 +48,25 @@ class UserCardController extends Controller } } + /** + * Updates an existing UserCard model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + /** * Finds the Product model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. diff --git a/frontend/modules/card/models/UserCard.php b/frontend/modules/card/models/UserCard.php new file mode 100644 index 0000000..8f736f0 --- /dev/null +++ b/frontend/modules/card/models/UserCard.php @@ -0,0 +1,45 @@ +where(['card_id' => \Yii::$app->request->get('id')])->all(), + 'skill_id' + ); + + if (!empty($skill)) { + $this->skill = $skill; + } + } + + public function afterSave($insert, $changedAttributes) + { + $post = \Yii::$app->request->post('UserCard'); + + if ($post['skill']) { + CardSkill::deleteAll(['card_id' => $this->id]); + + foreach ($post['skill'] as $item) { + $skill = new CardSkill(); + $skill->skill_id = $item; + $skill->card_id = $this->id; + + $skill->save(); + } + } + + parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub + } +} diff --git a/frontend/modules/card/views/user-card/_form.php b/frontend/modules/card/views/user-card/_form.php new file mode 100644 index 0000000..aaf3967 --- /dev/null +++ b/frontend/modules/card/views/user-card/_form.php @@ -0,0 +1,39 @@ + + +
+ + + +
+
+ field($model, 'skill')->widget( + Select2::class, + [ + 'data' => ArrayHelper::map(Skill::find()->all(), 'id', 'name'), + 'options' => ['placeholder' => '...', 'class' => 'form-control', 'multiple' => true], + 'pluginOptions' => [ + 'allowClear' => true + ], + ] + )->label('Навыки'); ?> +
+
+ +
+ 'btn btn-success']) ?> +
+ + + +
\ No newline at end of file diff --git a/frontend/modules/card/views/user-card/index.php b/frontend/modules/card/views/user-card/index.php index 9b3a781..75951e9 100644 --- a/frontend/modules/card/views/user-card/index.php +++ b/frontend/modules/card/views/user-card/index.php @@ -1 +1,7 @@ - \ No newline at end of file +title = 'Профиль'; + + echo $info; diff --git a/frontend/modules/card/views/user-card/update.php b/frontend/modules/card/views/user-card/update.php new file mode 100644 index 0000000..f674155 --- /dev/null +++ b/frontend/modules/card/views/user-card/update.php @@ -0,0 +1,14 @@ +title = "Редактировать профиль"; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/modules/card/views/user-card/view.php b/frontend/modules/card/views/user-card/view.php index 81b1fe6..4a7d7b8 100644 --- a/frontend/modules/card/views/user-card/view.php +++ b/frontend/modules/card/views/user-card/view.php @@ -9,7 +9,7 @@ use yii\widgets\DetailView; /* @var $skill \common\models\Skill */ /* @var $modelFildValue yii\data\ActiveDataProvider */ - +$this->title = 'Профиль'; ?>
@@ -48,7 +48,6 @@ use yii\widgets\DetailView; } ], ['label' => 'Добвлен', 'attribute' => 'created_at',], - ['label' => 'Изменен', 'attribute' => 'updated_at',], ], ]); ?> @@ -58,6 +57,9 @@ use yii\widgets\DetailView; name; ?> + + $model->id], ['class' => 'btn btn-success']); ?> +

Дополнительные сведения

-endPage() ?> \ No newline at end of file +endPage() ?>