Пример #1
0
 function statistics_get()
 {
     if (!$this->get('type')) {
         $this->response(NULL, 400);
     }
     $statistics = new Statistic();
     $statistics->order_by('number', 'asc')->get_by_type($this->get('type'));
     $scenario_options = array('played_most', 'played_least', 'season', 'evergreen');
     $person_options = array('player_complete_pfs', 'player_complete_core', 'gm_complete_pfs', 'gm_complete_core');
     $result = array();
     foreach ($statistics as $statistic) {
         $result[$statistic->id] = $statistic->to_array();
         if (in_array($this->get('type'), $person_options)) {
             $result[$statistic->id]['person'] = $statistic->person->to_array();
         } else {
             $result[$statistic->id]['scenario'] = $statistic->scenario->to_array();
         }
     }
     $this->response($result, 200);
 }