diff --git a/app/Models/ProjectTask.php b/app/Models/ProjectTask.php index 710ad3a8..1ffaf256 100644 --- a/app/Models/ProjectTask.php +++ b/app/Models/ProjectTask.php @@ -799,6 +799,11 @@ class ProjectTask extends AbstractModel $this->addLog($logText, $userid); $this->pushMsg('archived'); } + self::whereParentId($this->id)->update([ + 'archived_at' => $this->archived_at, + 'archived_userid' => $this->archived_userid, + 'archived_follow' => $this->archived_follow, + ]); $this->save(); }); return true; @@ -814,12 +819,11 @@ class ProjectTask extends AbstractModel AbstractModel::transaction(function () { if ($this->dialog_id) { $dialog = WebSocketDialog::find($this->dialog_id); - if ($dialog) { - $dialog->deleteDialog(); - } + $dialog?->deleteDialog(); } - $this->delete(); + self::whereParentId($this->id)->delete(); $this->addLog("删除{任务}:" . $this->name); + $this->delete(); }); if ($pushMsg) { $this->pushMsg('delete'); diff --git a/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php b/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php index 618e66f3..66e99ede 100644 --- a/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php +++ b/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php @@ -6,7 +6,7 @@ use Illuminate\Database\Migrations\Migration; class ProjectTasksUpdateSubtaskTime extends Migration { /** - * Run the migrations. + * 子任务同步主任务(任务时间) * * @return void */ diff --git a/database/migrations/2022_01_06_164034_project_tasks_update_subtask_archived_delete.php b/database/migrations/2022_01_06_164034_project_tasks_update_subtask_archived_delete.php new file mode 100644 index 00000000..7261f384 --- /dev/null +++ b/database/migrations/2022_01_06_164034_project_tasks_update_subtask_archived_delete.php @@ -0,0 +1,51 @@ +whereNotNull('archived_at') + ->chunkById(100, function ($lists) { + /** @var ProjectTask $task */ + foreach ($lists as $task) { + ProjectTask::whereParentId($task->id)->update([ + 'archived_at' => $task->archived_at, + 'archived_userid' => $task->archived_userid, + 'archived_follow' => $task->archived_follow, + ]); + } + }); + + // 删除 + ProjectTask::onlyTrashed() + ->whereParentId(0) + ->chunkById(100, function ($lists) { + /** @var ProjectTask $task */ + foreach ($lists as $task) { + ProjectTask::whereParentId($task->id)->update([ + 'deleted_at' => $task->deleted_at, + ]); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}