public function onAdd()
 {
     $items = post('items', []);
     $name = post('new_name');
     $totalPoints = post('new_total_points');
     $startDate = post('new_start_date');
     $endDate = post('new_end_date');
     $bonusPerDay = post('new_bonus_per_day');
     $bonusDays = post('new_bonus_days');
     $penaltyPerDay = post('new_penalty_per_day');
     $penaltyDays = post('new_penalty_days');
     $experience = new Model();
     $experience->name = $name;
     $experience->total_points = $totalPoints;
     $start = new DateTime($startDate);
     $experience->start_date = $start->format('c');
     $end = new DateTime($endDate);
     $experience->end_date = $end->format('c');
     $experience->bonus_per_day = $bonusPerDay;
     $experience->bonus_days = $bonusDays;
     $experience->penalty_per_day = $penaltyPerDay;
     $experience->penalty_days = $penaltyDays;
     $experience->save();
     $this->page['items'] = Model::all();
 }
Esempio n. 2
0
 private function onCreateComponentInstance()
 {
     if (post('component') == "experience") {
         // get component type from js
         $experience = new Experience();
         $experience->name = 'Experience';
         $experience->total_points = 1000;
         $experience->bonus_per_day = 1;
         $experience->penalty_per_day = 1;
         $experience->bonus_days = 5;
         $experience->penalty_days = 25;
         $experience->start_date = "Mon, Aug 31, 2015 12:00 AM";
         $experience->end_date = "Thu, Dec 17, 2015 12:00 AM";
         $experience->animate = 1;
         $experience->size = "medium";
         $experience->save();
         $instanceID = $experience->id;
     }
     return ['instanceID' => $instanceID];
 }