Esempio n. 1
0
 public function fetchStats()
 {
     $wakaPub = new WakaPub();
     $stats = $wakaPub->getStats($this->wakaId);
     $stats->userId = $this->id;
     if ($exists = $stats->findSaved()) {
         //$this->latestStatId = $exists->id;
         //$this->save();
         throw new Exception('Stats already exists', Exception::ALREADY_EXISTS);
     }
     $stats->save();
     $this->latestStatId = $stats->id;
     $this->save();
     foreach ($stats->details as $detail) {
         $detail->stat7id = $stats->id;
         $detail->typeId = StatType::getByText($detail->sectionText, $detail->typeText);
         $detail->save();
     }
 }