From 7cf76d91a0b1e989c013fbc99fbe06688e8da262 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Mon, 13 Dec 2021 00:27:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BD=92=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Project.php | 16 ++++++--- app/Models/ProjectTask.php | 7 ++-- ...2344_project_tasks_add_archived_follow.php | 34 +++++++++++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 database/migrations/2021_12_13_002344_project_tasks_add_archived_follow.php diff --git a/app/Models/Project.php b/app/Models/Project.php index 5acd0c60..43b810d5 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -267,7 +267,7 @@ class Project extends AbstractModel } /** - * 归档任务、取消归档 + * 归档项目、取消归档 * @param Carbon|null $archived_at 归档时间 * @return bool */ @@ -279,12 +279,20 @@ class Project extends AbstractModel $this->archived_at = null; $this->addLog("项目取消归档"); $this->pushMsg('add', $this); + ProjectTask::whereProjectId($this->id)->whereArchivedFollow(1)->update([ + 'archived_at' => null, + 'archived_follow' => 0 + ]); } else { - // 归档任务 + // 归档项目 $this->archived_at = $archived_at; $this->archived_userid = User::userid(); $this->addLog("项目归档"); $this->pushMsg('archived'); + ProjectTask::whereProjectId($this->id)->whereArchivedAt(null)->update([ + 'archived_at' => Carbon::now(), + 'archived_follow' => 1 + ]); } $this->save(); }); @@ -299,9 +307,7 @@ class Project extends AbstractModel { AbstractModel::transaction(function () { $dialog = WebSocketDialog::find($this->dialog_id); - if ($dialog) { - $dialog->deleteDialog(); - } + $dialog?->deleteDialog(); $columns = ProjectColumn::whereProjectId($this->id)->get(); foreach ($columns as $column) { $column->deleteColumn(false); diff --git a/app/Models/ProjectTask.php b/app/Models/ProjectTask.php index c2463e05..681bb06e 100644 --- a/app/Models/ProjectTask.php +++ b/app/Models/ProjectTask.php @@ -12,9 +12,8 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Request; /** - * Class ProjectTask + * App\Models\ProjectTask * - * @package App\Models * @property int $id * @property int|null $parent_id 父级任务ID * @property int|null $project_id 项目ID @@ -27,6 +26,7 @@ use Request; * @property string|null $end_at 计划结束时间 * @property string|null $archived_at 归档时间 * @property int|null $archived_userid 归档会员 + * @property int|null $archived_follow 跟随项目归档(项目取消归档时任务也取消归档) * @property string|null $complete_at 完成时间 * @property int|null $userid 创建人 * @property int|null $p_level 优先级 @@ -58,6 +58,7 @@ use Request; * @method static \Illuminate\Database\Query\Builder|ProjectTask onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask query() * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereArchivedAt($value) + * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereArchivedFollow($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereArchivedUserid($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereColor($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereColumnId($value) @@ -639,6 +640,7 @@ class ProjectTask extends AbstractModel if ($archived_at === null) { // 取消归档 $this->archived_at = null; + $this->archived_follow = 0; $this->addLog("任务取消归档:" . $this->name); $this->pushMsg('add', [ 'new_column' => null, @@ -648,6 +650,7 @@ class ProjectTask extends AbstractModel // 归档任务 $this->archived_at = $archived_at; $this->archived_userid = User::userid(); + $this->archived_follow = 0; $this->addLog("任务归档:" . $this->name); $this->pushMsg('archived'); } diff --git a/database/migrations/2021_12_13_002344_project_tasks_add_archived_follow.php b/database/migrations/2021_12_13_002344_project_tasks_add_archived_follow.php new file mode 100644 index 00000000..2b0d92a0 --- /dev/null +++ b/database/migrations/2021_12_13_002344_project_tasks_add_archived_follow.php @@ -0,0 +1,34 @@ +tinyInteger('archived_follow')->nullable()->default(0)->after('archived_userid')->comment('跟随项目归档(项目取消归档时任务也取消归档)'); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('project_tasks', function (Blueprint $table) { + $table->dropColumn("archived_follow"); + }); + } +}