where('category_id', $category_id)->pluck('project_id'); $project_ids = Project::query()->whereIn('id', $project_ids)->where('status', 0)->pluck('id'); $coach_ids = DB::table('service_project_has_coach')->whereIn('project_id', $project_ids)->pluck('coach_id'); $userWhere = ['status' => 1, 'auth_status' => 2]; $userPage = User::query()->whereIn('id', $coach_ids)->where($userWhere)->select($this->select_column)->paginate(); return ['list' => $userPage->items(), 'total' => $userPage->total()]; // $project = Project::query(); // $category_id = $params['categoryId'] ?? 1; // $project_ids = DB::table('service_project_has_category')->where('category_id', $category_id)->pluck('project_id'); // !$project_ids->isEmpty() && $project->whereIn('id', $project_ids); // $where['status'] = 0; // $projectPage = $project->where($where)->paginate(); // return ['list' => $projectPage->items(), 'total' => $projectPage->total()]; } public function getUser(array $params, int $id) { $category_id = $params['categoryId'] ?? 0; $user = User::query()->select([...$this->select_column, ...$this->show_column])->find($id); $category_id && ($user['project'] = $user->getProject($category_id)); return $user; } }