hasOne(Project::class, 'id', 'project_id'); } /** * 退出项目 */ public function exitProject() { 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(); } }