countAvailable() public method

Get the number of packages available
public countAvailable ( string $type = '' ) : integer
$type string The package type
return integer
Example #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]]);
 }