未完成项目概况

This commit is contained in:
kuaifan
2022-01-04 20:23:01 +08:00
parent f1f1d784ff
commit 186290e355
6 changed files with 487 additions and 192 deletions
+15 -6
View File
@@ -42,12 +42,21 @@ class ProjectUser extends AbstractModel
*/
public function exitProject()
{
$tasks = ProjectTask::whereProjectId($this->project_id)->authData($this->userid)->get();
foreach ($tasks as $task) {
if (ProjectTaskUser::whereTaskId($task->id)->whereUserid($this->userid)->delete()) {
$task->syncDialogUser();
}
}
ProjectTaskUser::whereProjectId($this->project_id)
->whereUserid($this->userid)
->chunk(100, function ($list) {
$tastIds = [];
foreach ($list as $item) {
if (!in_array($item->task_pid, $tastIds)) {
$tastIds[] = $item->task_pid;
}
$item->delete();
}
$tasks = ProjectTask::whereIn('id', $tastIds)->get();
foreach ($tasks as $task) {
$task->syncDialogUser();
}
});
$this->delete();
}
}