Airship\Cabin\Bridge\Blueprint\Skyport::countAvailable PHP Method

countAvailable() public method

Get the number of packages available
public countAvailable ( string $type = '' ) : integer
$type string The package type
return integer
    public function countAvailable(string $type = '') : int
    {
        if ($type) {
            $extra = ' AND packagetype = ?';
            $args = [$type];
        } else {
            $extra = '';
            $args = [];
        }
        return (int) $this->db->cell('
            SELECT
                count(packageid)
            FROM
                airship_package_cache
            WHERE
                NOT installed ' . $extra, ...$args);
    }

Usage Example

Esempio n. 1
0
 /**
  * @route ajax/admin/skyport/browse
  */
 public function ajaxGetAvailablePackages()
 {
     $post = $_POST ?? [];
     $type = '';
     $headline = 'Available Extensions';
     if (isset($post['type'])) {
         switch ($post['type']) {
             case 'cabin':
                 $headline = 'Available Cabins';
                 $type = 'Cabin';
                 break;
             case 'gadget':
                 $headline = 'Available Gadgets';
                 $type = 'Gadget';
                 break;
             case 'motif':
                 $headline = 'Available Motifs';
                 $type = 'Motif';
                 break;
         }
     }
     $query = (string) ($post['query'] ?? '');
     $numAvailable = $this->skyport->countAvailable($type);
     list($page, $offset) = $this->getPaginated($numAvailable);
     $this->lens('skyport/list', ['headline' => $headline, 'extensions' => $this->skyport->getAvailable($type, $query, $offset, $this->perPage), 'pagination' => ['count' => $numAvailable, 'page' => $page, 'per_page' => $this->perPage]]);
 }