where("status",1)->pluck("department_name","department_id"); //$departments = collect($departments)->toArray(); return $departments; } /** * 获得所有部门的总人数 * @return mixed */ public function allPcount($activityId){ $departments = Department::where("activity_id",$activityId)->where("status",1)->pluck("user_num","department_id"); return collect($departments)->toArray(); } /** * 获取部门人员Id * @param $departmentId * @return mixed */ public function getUserIdsByDepartmentId($departmentId){ $userIds = User::where("department_id",$departmentId)->pluck("user_id"); return $userIds; } /** * 获得部门名称 * @param $departmentId * @return string */ public function getDepartmentName($departmentId){ $departmentName = ""; if(!empty($departmentId)){ $departmentName = Redis::get(self::DEPARTMENTS.":".$departmentId); if(empty($departmentName)){ $department = Department::find($departmentId); if($department){ $departmentName = $department->department_name; Redis::set(self::DEPARTMENTS.":".$departmentId,$departmentName); Redis::expire(self::DEPARTMENTS.":".$departmentId,600); } } } return $departmentName; } }