diff --git a/backend/config/main.php b/backend/config/main.php
index 4fad469..992ba79 100755
--- a/backend/config/main.php
+++ b/backend/config/main.php
@@ -68,11 +68,14 @@ return [
'employee' => [
'class' => 'backend\modules\employee\Employee',
],
+ 'task' => [
+ 'class' => 'backend\modules\task\Task',
+ ],
],
'components' => [
'request' => [
'csrfParam' => '_csrf-backend',
- 'baseUrl' => '/secure',
+ 'baseUrl' => '', //TODO /secure
'parsers' => [
'application/json' => 'yii\web\JsonParser',
'text/xml' => 'yii/web/XmlParser',
diff --git a/backend/modules/task/Task.php b/backend/modules/task/Task.php
new file mode 100644
index 0000000..791b514
--- /dev/null
+++ b/backend/modules/task/Task.php
@@ -0,0 +1,24 @@
+render('index');
+ }
+}
diff --git a/backend/modules/task/controllers/TaskController.php b/backend/modules/task/controllers/TaskController.php
new file mode 100644
index 0000000..53f893f
--- /dev/null
+++ b/backend/modules/task/controllers/TaskController.php
@@ -0,0 +1,127 @@
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['POST'],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Lists all Task models.
+ * @return mixed
+ */
+ public function actionIndex()
+ {
+ $searchModel = new TaskSearch();
+ $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+ return $this->render('index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+ /**
+ * Displays a single Task model.
+ * @param integer $id
+ * @return mixed
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionView($id)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($id),
+ ]);
+ }
+
+ /**
+ * Creates a new Task model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return mixed
+ */
+ public function actionCreate()
+ {
+ $model = new Task();
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id]);
+ }
+
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Updates an existing Task 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(['view', 'id' => $model->id]);
+ }
+
+ return $this->render('update', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Deletes an existing Task model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ * @param integer $id
+ * @return mixed
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionDelete($id)
+ {
+ $this->findModel($id)->delete();
+
+ return $this->redirect(['index']);
+ }
+
+ /**
+ * Finds the Task model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param integer $id
+ * @return Task the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = Task::findOne($id)) !== null) {
+ return $model;
+ }
+
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+}
diff --git a/backend/modules/task/controllers/TaskUserController.php b/backend/modules/task/controllers/TaskUserController.php
new file mode 100644
index 0000000..0e5fdfe
--- /dev/null
+++ b/backend/modules/task/controllers/TaskUserController.php
@@ -0,0 +1,127 @@
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['POST'],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Lists all TaskUser models.
+ * @return mixed
+ */
+ public function actionIndex()
+ {
+ $searchModel = new TaskUserSearch();
+ $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+ return $this->render('index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+ /**
+ * Displays a single TaskUser model.
+ * @param integer $id
+ * @return mixed
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionView($id)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($id),
+ ]);
+ }
+
+ /**
+ * Creates a new TaskUser model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return mixed
+ */
+ public function actionCreate()
+ {
+ $model = new TaskUser();
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id]);
+ }
+
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Updates an existing TaskUser 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(['view', 'id' => $model->id]);
+ }
+
+ return $this->render('update', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Deletes an existing TaskUser model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ * @param integer $id
+ * @return mixed
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionDelete($id)
+ {
+ $this->findModel($id)->delete();
+
+ return $this->redirect(['index']);
+ }
+
+ /**
+ * Finds the TaskUser model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param integer $id
+ * @return TaskUser the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = TaskUser::findOne($id)) !== null) {
+ return $model;
+ }
+
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+}
diff --git a/backend/modules/task/models/Task.php b/backend/modules/task/models/Task.php
new file mode 100644
index 0000000..3d9d23e
--- /dev/null
+++ b/backend/modules/task/models/Task.php
@@ -0,0 +1,8 @@
+ $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,
+ 'project_id' => $this->project_id,
+ 'status' => $this->status,
+ 'created_at' => $this->created_at,
+ 'updated_at' => $this->updated_at,
+ 'project_user_id' => $this->project_user_id,
+ 'user_id' => $this->user_id,
+ ]);
+
+ $query->andFilterWhere(['like', 'title', $this->title])
+ ->andFilterWhere(['like', 'description', $this->description]);
+
+ return $dataProvider;
+ }
+}
diff --git a/backend/modules/task/models/TaskUser.php b/backend/modules/task/models/TaskUser.php
new file mode 100644
index 0000000..81eb21e
--- /dev/null
+++ b/backend/modules/task/models/TaskUser.php
@@ -0,0 +1,8 @@
+ $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,
+ 'task_id' => $this->task_id,
+ 'project_user_id' => $this->project_user_id,
+ ]);
+
+ return $dataProvider;
+ }
+}
diff --git a/backend/modules/task/views/default/index.php b/backend/modules/task/views/default/index.php
new file mode 100644
index 0000000..d8e5c97
--- /dev/null
+++ b/backend/modules/task/views/default/index.php
@@ -0,0 +1,12 @@
+
+
= $this->context->action->uniqueId ?>
+
+ This is the view content for action "= $this->context->action->id ?>".
+ The action belongs to the controller "= get_class($this->context) ?>"
+ in the "= $this->context->module->id ?>" module.
+
+
+ You may customize this page by editing the following file:
+ = __FILE__ ?>
+
+
diff --git a/backend/modules/task/views/task-user/_form.php b/backend/modules/task/views/task-user/_form.php
new file mode 100644
index 0000000..1188b9b
--- /dev/null
+++ b/backend/modules/task/views/task-user/_form.php
@@ -0,0 +1,25 @@
+
+
+
diff --git a/backend/modules/task/views/task-user/_search.php b/backend/modules/task/views/task-user/_search.php
new file mode 100644
index 0000000..95b3dfa
--- /dev/null
+++ b/backend/modules/task/views/task-user/_search.php
@@ -0,0 +1,31 @@
+
+
+
+
+ ['index'],
+ 'method' => 'get',
+ ]); ?>
+
+ = $form->field($model, 'id') ?>
+
+ = $form->field($model, 'task_id') ?>
+
+ = $form->field($model, 'project_user_id') ?>
+
+
+ = Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
+ = Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
+
+
+
+
+
diff --git a/backend/modules/task/views/task-user/create.php b/backend/modules/task/views/task-user/create.php
new file mode 100644
index 0000000..ab6a619
--- /dev/null
+++ b/backend/modules/task/views/task-user/create.php
@@ -0,0 +1,20 @@
+title = 'Create Task User';
+$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/backend/modules/task/views/task-user/index.php b/backend/modules/task/views/task-user/index.php
new file mode 100644
index 0000000..87c16fd
--- /dev/null
+++ b/backend/modules/task/views/task-user/index.php
@@ -0,0 +1,35 @@
+title = 'Task Users';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+ render('_search', ['model' => $searchModel]); ?>
+
+
+ = Html::a('Create Task User', ['create'], ['class' => 'btn btn-success']) ?>
+
+
+ = GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+
+ 'id',
+ 'task_id',
+ 'project_user_id',
+
+ ['class' => 'yii\grid\ActionColumn'],
+ ],
+ ]); ?>
+
diff --git a/backend/modules/task/views/task-user/update.php b/backend/modules/task/views/task-user/update.php
new file mode 100644
index 0000000..262a7e5
--- /dev/null
+++ b/backend/modules/task/views/task-user/update.php
@@ -0,0 +1,21 @@
+title = 'Update Task User: ' . $model->id;
+$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
+$this->params['breadcrumbs'][] = 'Update';
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/backend/modules/task/views/task-user/view.php b/backend/modules/task/views/task-user/view.php
new file mode 100644
index 0000000..7745f79
--- /dev/null
+++ b/backend/modules/task/views/task-user/view.php
@@ -0,0 +1,38 @@
+title = $model->id;
+$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+\yii\web\YiiAsset::register($this);
+?>
+
+
+
= Html::encode($this->title) ?>
+
+
+ = Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+ = Html::a('Delete', ['delete', 'id' => $model->id], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => 'Are you sure you want to delete this item?',
+ 'method' => 'post',
+ ],
+ ]) ?>
+
+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'task_id',
+ 'project_user_id',
+ ],
+ ]) ?>
+
+
diff --git a/backend/modules/task/views/task/_form.php b/backend/modules/task/views/task/_form.php
new file mode 100644
index 0000000..7192447
--- /dev/null
+++ b/backend/modules/task/views/task/_form.php
@@ -0,0 +1,37 @@
+
+
+
diff --git a/backend/modules/task/views/task/_search.php b/backend/modules/task/views/task/_search.php
new file mode 100644
index 0000000..f42ac3b
--- /dev/null
+++ b/backend/modules/task/views/task/_search.php
@@ -0,0 +1,43 @@
+
+
+
+
+ ['index'],
+ 'method' => 'get',
+ ]); ?>
+
+ = $form->field($model, 'id') ?>
+
+ = $form->field($model, 'project_id') ?>
+
+ = $form->field($model, 'title') ?>
+
+ = $form->field($model, 'status') ?>
+
+ = $form->field($model, 'created_at') ?>
+
+ field($model, 'updated_at') ?>
+
+ field($model, 'project_user_id') ?>
+
+ field($model, 'user_id') ?>
+
+ field($model, 'description') ?>
+
+
+ = Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
+ = Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
+
+
+
+
+
diff --git a/backend/modules/task/views/task/create.php b/backend/modules/task/views/task/create.php
new file mode 100644
index 0000000..b70a677
--- /dev/null
+++ b/backend/modules/task/views/task/create.php
@@ -0,0 +1,20 @@
+title = 'Create Task';
+$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/backend/modules/task/views/task/index.php b/backend/modules/task/views/task/index.php
new file mode 100644
index 0000000..68e0b80
--- /dev/null
+++ b/backend/modules/task/views/task/index.php
@@ -0,0 +1,41 @@
+title = 'Tasks';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+ render('_search', ['model' => $searchModel]); ?>
+
+
+ = Html::a('Create Task', ['create'], ['class' => 'btn btn-success']) ?>
+
+
+ = GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+
+ 'id',
+ 'project_id',
+ 'title',
+ 'status',
+ 'created_at',
+ //'updated_at',
+ //'project_user_id',
+ //'user_id',
+ //'description',
+
+ ['class' => 'yii\grid\ActionColumn'],
+ ],
+ ]); ?>
+
diff --git a/backend/modules/task/views/task/update.php b/backend/modules/task/views/task/update.php
new file mode 100644
index 0000000..f6e4332
--- /dev/null
+++ b/backend/modules/task/views/task/update.php
@@ -0,0 +1,21 @@
+title = 'Update Task: ' . $model->title;
+$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
+$this->params['breadcrumbs'][] = 'Update';
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/backend/modules/task/views/task/view.php b/backend/modules/task/views/task/view.php
new file mode 100644
index 0000000..3fdb9da
--- /dev/null
+++ b/backend/modules/task/views/task/view.php
@@ -0,0 +1,44 @@
+title = $model->title;
+$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+\yii\web\YiiAsset::register($this);
+?>
+
+
+
= Html::encode($this->title) ?>
+
+
+ = Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+ = Html::a('Delete', ['delete', 'id' => $model->id], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => 'Are you sure you want to delete this item?',
+ 'method' => 'post',
+ ],
+ ]) ?>
+
+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'project_id',
+ 'title',
+ 'status',
+ 'created_at',
+ 'updated_at',
+ 'project_user_id',
+ 'user_id',
+ 'description',
+ ],
+ ]) ?>
+
+
diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php
index fb09de7..6c0e32e 100755
--- a/backend/views/layouts/left.php
+++ b/backend/views/layouts/left.php
@@ -26,7 +26,7 @@
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position'],
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill'],
],
- 'visible' => Yii::$app->user->can('confidential_information')
+ // TODO visible 'visible' => Yii::$app->user->can('confidential_information')
],
[
'label' => 'Профили', 'icon' => 'address-book-o', 'url' => '#', 'active' => \Yii::$app->controller->id == 'user-card',
@@ -38,12 +38,21 @@
['label' => 'Менеджеры', 'icon' => 'user-circle-o', 'url' => ['/employee/manager'], 'active' => \Yii::$app->controller->id == 'manager'],
['label' => 'Работники', 'icon' => 'user', 'url' => ['/employee/manager-employee'], 'active' => \Yii::$app->controller->id == 'manager-employee'],
],
- 'visible' => Yii::$app->user->can('confidential_information')
+ // TODO visible 'visible' => Yii::$app->user->can('confidential_information')
],
[
'label' => 'Проекты', 'icon' => 'cubes', 'url' => ['#'], 'active' => \Yii::$app->controller->id == 'project',
'items' => $projectItems,
- 'visible' => Yii::$app->user->can('confidential_information')
+ // TODO visible 'visible' => Yii::$app->user->can('confidential_information')
+ ],
+ [
+ 'label' => 'Задачи', 'icon' => '', 'url' => '#',
+ 'items' => [
+ ['label' => 'Задачи', 'icon' => '', 'url' => ['/task/task'], 'active' => \Yii::$app->controller->id == 'task'],
+ ['label' => 'Сотруднике на задаче', 'icon' => '', 'url' => ['/task/task-user'], 'active' => \Yii::$app->controller->id == 'task-user'],
+ ],
+
+ // TODO visible 'visible' => Yii::$app->user->can('confidential_information')
],
['label' => 'Компании', 'icon' => 'building', 'url' => ['/company/company'], 'active' => \Yii::$app->controller->id == 'company', 'visible' => Yii::$app->user->can('confidential_information')],
[
@@ -52,7 +61,7 @@
['label' => 'Компании', 'icon' => 'building', 'url' => ['/hh/hh'], 'active' => \Yii::$app->controller->id == 'hh'],
['label' => 'Вакансии', 'icon' => 'user-md', 'url' => ['/hh/hh-job'], 'active' => \Yii::$app->controller->id == 'hh-job'],
],
- 'visible' => Yii::$app->user->can('confidential_information')
+ // TODO visible 'visible' => Yii::$app->user->can('confidential_information')
],
['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balance/balance'], 'active' => \Yii::$app->controller->id == 'balance', 'visible' => Yii::$app->user->can('confidential_information')],
['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday', 'visible' => Yii::$app->user->can('confidential_information')],
diff --git a/common/models/Task.php b/common/models/Task.php
new file mode 100644
index 0000000..64a5f7a
--- /dev/null
+++ b/common/models/Task.php
@@ -0,0 +1,101 @@
+ 255],
+ [['description'], 'string', 'max' => 500],
+ [['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
+ [['project_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectUser::className(), 'targetAttribute' => ['project_user_id' => 'id']],
+ [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id' => 'ID',
+ 'project_id' => 'Project ID',
+ 'title' => 'Title',
+ 'status' => 'Status',
+ 'created_at' => 'Created At',
+ 'updated_at' => 'Updated At',
+ 'project_user_id' => 'Project User ID',
+ 'user_id' => 'User ID',
+ 'description' => 'Description',
+ ];
+ }
+
+ /**
+ * @return \yii\db\ActiveQuery
+ */
+ public function getProject()
+ {
+ return $this->hasOne(Project::className(), ['id' => 'project_id']);
+ }
+
+ /**
+ * @return \yii\db\ActiveQuery
+ */
+ public function getProjectUser()
+ {
+ return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
+ }
+
+ /**
+ * @return \yii\db\ActiveQuery
+ */
+ public function getUser()
+ {
+ return $this->hasOne(User::className(), ['id' => 'user_id']);
+ }
+
+ /**
+ * @return \yii\db\ActiveQuery
+ */
+ public function getTaskUsers()
+ {
+ return $this->hasMany(TaskUser::className(), ['task_id' => 'id']);
+ }
+}
diff --git a/common/models/TaskUser.php b/common/models/TaskUser.php
new file mode 100644
index 0000000..c545fc4
--- /dev/null
+++ b/common/models/TaskUser.php
@@ -0,0 +1,66 @@
+ true, 'targetClass' => ProjectUser::className(), 'targetAttribute' => ['project_user_id' => 'id']],
+ [['task_id'], 'exist', 'skipOnError' => true, 'targetClass' => Task::className(), 'targetAttribute' => ['task_id' => 'id']],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id' => 'ID',
+ 'task_id' => 'Task ID',
+ 'project_user_id' => 'Project User ID',
+ ];
+ }
+
+ /**
+ * @return \yii\db\ActiveQuery
+ */
+ public function getProjectUser()
+ {
+ return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
+ }
+
+ /**
+ * @return \yii\db\ActiveQuery
+ */
+ public function getTask()
+ {
+ return $this->hasOne(Task::className(), ['id' => 'task_id']);
+ }
+}
diff --git a/console/migrations/m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table.php b/console/migrations/m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table.php
new file mode 100644
index 0000000..0ff6477
--- /dev/null
+++ b/console/migrations/m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table.php
@@ -0,0 +1,54 @@
+dropForeignKey('project_user_ibfk_user_card', 'project_user');
+ $this->dropColumn('project_user', 'card_id');
+ $this->addColumn('project_user', 'user_id', $this->integer(11)->notNull());
+ $this->addForeignKey('user_project_user', 'project_user', 'user_id', 'user', 'id');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $this->dropForeignKey('user_project_user', 'project_user');
+ $this->dropColumn('project_user', 'user_id');
+ $this->addColumn('project_user', 'card_id', $this->integer(11)->notNull());
+ $this->addForeignKey(
+ 'project_user_ibfk_user_card',
+ 'project_user',
+ 'card_id',
+ 'user_card',
+ 'id',
+ 'RESTRICT',
+ 'CASCADE'
+ );
+ }
+
+ /*
+ // Use up()/down() to run migration code without a transaction.
+ public function up()
+ {
+
+ }
+
+ public function down()
+ {
+ echo "m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table cannot be reverted.\n";
+
+ return false;
+ }
+ */
+}
diff --git a/console/migrations/m211123_083938_create_task_table.php b/console/migrations/m211123_083938_create_task_table.php
new file mode 100644
index 0000000..eb1a437
--- /dev/null
+++ b/console/migrations/m211123_083938_create_task_table.php
@@ -0,0 +1,43 @@
+createTable('{{%task}}', [
+ 'id' => $this->primaryKey(),
+ 'project_id' => $this->integer(11)->notNull(),
+ 'title' => $this->string(),
+ 'status' => $this->integer(),
+ 'created_at' => $this->dateTime(),
+ 'updated_at' => $this->dateTime(),
+ 'project_user_id' => $this->integer(),
+ 'user_id' => $this->integer(),
+ 'description' => $this->string(500),
+ ]);
+ $this->addForeignKey('task_project', 'task',
+ 'project_id', 'project', 'id');
+ $this->addForeignKey('task_project_user', 'task',
+ 'project_user_id', 'project_user', 'id');
+ $this->addForeignKey('task_user', 'task', 'user_id', 'user', 'id');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $this->dropForeignKey('task_project', 'task');
+ $this->dropForeignKey('task_project_user', 'task');
+ $this->dropForeignKey('task_user', 'task');
+ $this->dropTable('{{%task}}');
+ }
+}
diff --git a/console/migrations/m211123_085751_create_task_user_table.php b/console/migrations/m211123_085751_create_task_user_table.php
new file mode 100644
index 0000000..91bc6a7
--- /dev/null
+++ b/console/migrations/m211123_085751_create_task_user_table.php
@@ -0,0 +1,35 @@
+createTable('{{%task_user}}', [
+ 'id' => $this->primaryKey(),
+ 'task_id' => $this->integer(),
+ 'project_user_id' => $this->integer(),
+ ]);
+ $this->addForeignKey('task_task_user', 'task_user',
+ 'task_id', 'task', 'id');
+ $this->addForeignKey('project_user_task_user', 'task_user',
+ 'project_user_id', 'project_user', 'id');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $this->dropForeignKey('task_task_user', 'task_user');
+ $this->dropForeignKey('project_user_task_user', 'task_user');
+ $this->dropTable('{{%task_user}}');
+ }
+}