task manager
This commit is contained in:
@ -101,6 +101,14 @@ class Project extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(Company::class, ['id' => 'company_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->hasMany(ProjectColumn::class, ['project_id' => 'id'])->with('tasks');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
|
@ -22,6 +22,7 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
||||
{
|
||||
const STATUS_ACTIVE = 1;
|
||||
const STATUS_DISABLE = 0;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -30,6 +31,30 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
||||
return 'project_column';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'title',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'project_id',
|
||||
'status',
|
||||
'tasks',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function extraFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -92,4 +117,12 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
||||
{
|
||||
return $this->hasOne(Project::className(), ['id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getTasks()
|
||||
{
|
||||
return $this->hasMany(ProjectTask::class, ['column_id' => 'id'])->with('taskUsers');
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ use yii\helpers\ArrayHelper;
|
||||
* @property int $status
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property int $card_id_creator
|
||||
* @property int $card_id
|
||||
* @property int $column_id
|
||||
* @property int $user_id
|
||||
* @property string $description
|
||||
*
|
||||
* @property Project $project
|
||||
@ -54,15 +54,15 @@ class ProjectTask extends ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['project_id', 'status', 'title', 'description', 'card_id_creator',], 'required'],
|
||||
[['project_id', 'status', 'card_id_creator', 'card_id'], 'integer'],
|
||||
[['project_id', 'status', 'title', 'description',], 'required'],
|
||||
[['project_id', 'status', 'column_id', 'user_id'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
['title', 'unique', 'targetAttribute' => ['title', 'project_id'], 'message'=>'Такая задача уже создана'],
|
||||
['title', 'unique', 'targetAttribute' => ['title', 'project_id'], 'message' => 'Такая задача уже создана'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
[['description'], 'string', 'max' => 500],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['card_id' => 'id']],
|
||||
[['card_id_creator'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['card_id_creator' => 'id']],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
[['column_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectColumn::className(), 'targetAttribute' => ['column_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
@ -79,14 +79,33 @@ class ProjectTask extends ActiveRecord
|
||||
'created_at' => 'Дата создания',
|
||||
'updated_at' => 'Дата обновления',
|
||||
'description' => 'Описание',
|
||||
'card_id_creator' => 'Создатель задачи',
|
||||
'card_id' => 'Наблюдатель',
|
||||
'user_id' => 'Создатель задачи',
|
||||
'column_id' => 'Колонка',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'project_id',
|
||||
'title',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'description',
|
||||
'status',
|
||||
'column_id',
|
||||
'user_id',
|
||||
'taskUsers',
|
||||
];
|
||||
}
|
||||
|
||||
public function beforeDelete()
|
||||
{
|
||||
foreach ($this->taskUsers as $taskUser){
|
||||
foreach ($this->taskUsers as $taskUser) {
|
||||
$taskUser->delete();
|
||||
}
|
||||
return parent::beforeDelete();
|
||||
@ -108,14 +127,12 @@ class ProjectTask extends ActiveRecord
|
||||
return $this->hasOne(User::className(), ['id' => 'user_id']);
|
||||
}
|
||||
|
||||
public function getUserCard()
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getColumn(): ActiveQuery
|
||||
{
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'card_id']);
|
||||
}
|
||||
|
||||
public function getUserCardCreator()
|
||||
{
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'card_id_creator']);
|
||||
return $this->hasOne(ProjectColumn::class, ['id' => 'column_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,7 +9,7 @@ use yii\db\ActiveQuery;
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $task_id
|
||||
* @property int $project_user_id
|
||||
* @property int $user_id
|
||||
*
|
||||
* @property ProjectUser $projectUser
|
||||
* @property ProjectTask $task
|
||||
@ -30,13 +30,31 @@ class ProjectTaskUser extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['task_id', 'project_user_id'], 'required'],
|
||||
['project_user_id', 'unique', 'targetAttribute' => ['task_id', 'project_user_id'], 'message'=>'Уже закреплён(ы) за задачей'],
|
||||
[['project_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectUser::className(), 'targetAttribute' => ['project_user_id' => 'id']],
|
||||
[['task_id', 'user_id'], 'required'],
|
||||
['user_id', 'unique', 'targetAttribute' => ['task_id', 'user_id'], 'message' => 'Уже закреплён(ы) за задачей'],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
[['task_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectTask::className(), 'targetAttribute' => ['task_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'task_id',
|
||||
'user_id',
|
||||
'fio' => function () {
|
||||
return $this->user->userCard->fio ?? $this->user->username;
|
||||
},
|
||||
'avatar' => function () {
|
||||
return $this->user->userCard->photo ?? '';
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -45,16 +63,13 @@ class ProjectTaskUser extends \yii\db\ActiveRecord
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'task_id' => 'Задача',
|
||||
'project_user_id' => 'Сотрудник',
|
||||
'user_id' => 'Сотрудник',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getProjectUser()
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
|
||||
return $this->hasOne(User::class, ['id' => 'user_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user