code: public function getAuthorities() {
          //Get All authorities from the database
          $statement = $this->database->select("a.*, count(p.permission) AS permissions")
                                      ->from("?authority a")
                                      ->join("?authority_permissions p", "a.authority_id=p.authority_id", "LEFT")
                                      ->groupBy("a.authority_name")
                                       ->orderBy("a.lft", "ASC")->prepare();
          $results = $statement->execute();
  
          //Authorities Obbject
          $rows = $results->fetchAll();
          $authorities = array();
          $right = array();
          foreach ($rows as $authority) {
  
              if (count($right) > 0) {
                  while ($right[count($right) - 1] < $authority['rgt']) {
                      array_pop($right);
                  }
              }
              //Authority Indent
              $authority["indent"] = sizeof($right);
              //Authority Permissions;
              if ((int) $authority['permissions'] > 0) {
  
                  $authority['permissions'] = $this->database->select('p.*')->from("?authority_permissions p")->where("p.authority_id =", $authority['authority_id'])->run()->fetchAll();
              }
              $authorities[] = $authority;
              $right[] = $authority['rgt'];
          }
  
          return $authorities;
      }
docs: Returns a processed array of authority groups
  @return array