'like', 'status' => '=', ]; protected bool $asTree = true; /** * * @param int|array $id * @return array */ public function findFollowDepartments(int|array $id): array { if (!is_array($id)) { $id = [$id]; } $followDepartmentIds = $this->whereIn($this->getParentIdColumn(), $id)->pluck('id')->toArray(); if (! empty($followDepartmentIds)) { $followDepartmentIds = array_merge($followDepartmentIds, $this->findFollowDepartments($followDepartmentIds)); } return $followDepartmentIds; } }