Esempio n. 1
0
 /**
  * process the results from the query
  *
  * @param json $results JSON results from the call
  * @return mixed
  */
 public function processResults($results)
 {
     $Collection = new \Cartalyst\Collections\Collection();
     if ($this->validate($results) && $this->isSuccess($results)) {
         foreach ($results['data'] as $item) {
             if (strtolower($item['values']['maximum_bw']['0']) === 'unlimited') {
                 $bandwidth = 'Unlimited';
             } else {
                 $bandwidth = $item['values']['maximum_bw']['0'] / 1073741824 . ' GB';
             }
             if (isset($item['values']['server_quota']['0'])) {
                 $diskSpace = $item['values']['server_quota']['0'];
             } else {
                 $diskSpace = 'Unlimited';
             }
             $Plan = new Plan();
             $Plan->fill(['id' => $item['name'], 'name' => $item['values']['name']['0'], 'bandwidth' => $bandwidth, 'disk_space' => $diskSpace]);
             $Collection->put($Plan->id, $Plan);
         }
     }
     return $Collection;
 }
Esempio n. 2
0
 /**
  * process the results from the query
  *
  * @param json $results JSON results from the call
  * @return mixed
  */
 public function processResults($results)
 {
     $Collection = new \Cartalyst\Collections\Collection();
     if ($this->validate($results) && $this->isSuccess($results)) {
         foreach ($results['data'] as $item) {
             $itemData = ['name' => $item['name']];
             foreach ($item['values'] as $key => $value) {
                 if (count($value) > 1) {
                     $itemData[$key] = new \Cartalyst\Collections\Collection($value);
                 } else {
                     $itemData[$key] = $value['0'];
                 }
             }
             $Domain = new Domain();
             $Domain->fill($itemData);
             $Collection->put($Domain->id, $Domain);
         }
     }
     if ($Collection->count() === 1) {
         return $Collection->first();
     }
     return $Collection;
 }