Airship\Cabin\Bridge\Blueprint\UserAccounts::numUsers PHP Method

numUsers() public method

How many users exist?
public numUsers ( ) : integer
return integer
    public function numUsers() : int
    {
        return (int) $this->db->cell('SELECT count(*) FROM airship_users');
    }

Usage Example

Esempio n. 1
0
 /**
  * List the users
  *
  * @route crew/users
  */
 public function users()
 {
     $get = $this->httpGetParams();
     list($offset, $limit) = $this->getOffsetAndLimit($get['page'] ?? 0);
     $suffix = '';
     $dir = 'ASC';
     if (\array_key_exists('dir', $get)) {
         if ($get['dir'] === 'DESC') {
             $dir = 'DESC';
         }
     }
     if (\array_key_exists('sort', $get)) {
         switch ($get['sort']) {
             case 'username':
             case 'display_name':
                 $suffix = \http_build_query(['sort' => $get['sort'], 'dir' => $dir]) . '&';
                 $users = $this->account->listUsers($offset, $limit, $get['sort'], $dir);
                 break;
             default:
                 $users = $this->account->listUsers($offset, $limit);
         }
     } else {
         $users = $this->account->listUsers($offset, $limit);
     }
     $this->lens('crew/user_list', ['active_link' => 'bridge-link-admin-crew-users', 'users' => $users, 'pagination' => ['base' => $this->airship_cabin_prefix . '/crew/users', 'suffix' => '?' . $suffix . 'page=', 'count' => $this->account->numUsers(), 'page' => (int) \ceil($offset / ($limit ?? 1)) + 1, 'per_page' => $limit]]);
 }