$org_id])->value('path'); // $pathArr = explode('-', $path); // if(empty($pathArr[1])) return []; // $rootPath = $pathArr[0].'-'.$pathArr[1].'-'; // $closetIdList = self::where([['path', 'like', $rootPath]])->column('id'); $closetIdList = self::column('id'); return $closetIdList; } /** * 获取关联子组织id */ public function getChildOrg($org_id) { $path = self::where(['id'=>$org_id])->value('path'); $childIdList = self::where([['path', 'like', $path.'%']])->column('id'); return $childIdList; } /** * 获取关联每个节点的员工列表 */ public function employee() { return $this->hasMany(Employee::class); } public function employees() { return $this->hasMany(Employee::class, 'root_id'); } public function company() { return $this->hasOne(Company::class, 'root_id'); } }