Esempio n. 1
0
 function formDestinationFinderResponse($input)
 {
     $list = new Collection();
     $data = json_decode($input, true);
     if (isset($data['FareInfo'])) {
         $fares = $data['FareInfo'];
         foreach ($fares as $fare) {
             $fareInfo = new FareInfo();
             $airPortCode = $fare['DestinationLocation'];
             if ($list->keyExists($airPortCode)) {
                 $fareInfo = $list->getItem($airPortCode);
             } else {
                 $geo = $this->translate($airPortCode);
                 $fareInfo->id = $airPortCode;
                 $fareInfo->coords = new Geo($geo['latitude'], $geo['longitude']);
                 $fareInfo->city = $geo['city'];
                 $fareInfo->currencyCode = $fare['CurrencyCode'];
                 if (isset($fare['DestinationRank'])) {
                     $fareInfo->destinationRank = $fare['DestinationRank'];
                 }
                 if (isset($fare['Theme'])) {
                     $fareInfo->theme = $fare['Theme'];
                 }
                 $list->addItem($fareInfo, $airPortCode);
             }
             $fareObj = new Fare();
             $fareObj->lowestFare = $fare['LowestFare'];
             $fareObj->lowestNonStopFare = $fare['LowestNonStopFare'];
             $fareObj->departureDateTime = $fare['DepartureDateTime'];
             $fareObj->returnDateTime = $fare['ReturnDateTime'];
             $fareInfo->fares[] = $fareObj;
         }
     }
     return json_encode(array_values($list->items));
 }
Esempio n. 2
0
 /**
  * Set and get pie chart
  * 
  * @param  Collection $data
  * @return Collection
  */
 public function getPieChart($data)
 {
     foreach ($data as $key => $value) {
         $i = 0;
         $dataset[$key] = collect();
         foreach ($data->get($key) as $k => $v) {
             $color = new Color(config('chartjs.colors.' . $i));
             $dataset[$key]->push(['value' => $v, 'color' => '#' . $color->lighten(20), 'highlight' => '#' . $color->lighten(25), 'label' => $k]);
             $i++;
         }
     }
     return $dataset;
 }