select()->toArray(); $byId = []; foreach ($rows as $row) { $byId[(int) $row['id']] = $row; } $enabled = []; foreach ($byId as $id => $row) { $current = $id; $visited = []; while ($current > 0) { if (isset($visited[$current]) || !isset($byId[$current]) || (int) $byId[$current]['is_disable'] !== 0) { continue 2; } $visited[$current] = true; $current = (int) $byId[$current]['pid']; } $enabled[] = $id; } return $enabled; } public static function has(string $permission): bool { return SystemMenu::whereIn('id', self::ids())->where('perms', $permission)->count() > 0; } }