Example #1
0
 protected function save(Model_Match $match, $post)
 {
     //Saving match
     $match->date = date('Y-m-d H:i:s');
     $match->player_1_id = $post['player_1_id'];
     $match->player_2_id = $post['player_2_id'];
     $match->player_1_score = $post['player_1_score'];
     $match->player_1_team = $post['player_1_team'];
     $match->player_2_score = $post['player_2_score'];
     $match->player_2_team = $post['player_2_team'];
     $match->save();
     $this->save_player_results($match, $post);
 }
Example #2
0
 /**
  * Дейсвтие-обработчик ПОСТ-запроса на изменения кол-ва комментов ВК
  */
 public function action_change_comments_num()
 {
     if (\Input::method() == 'POST') {
         $id = (int) \Input::post('id');
         $num = (int) \Input::post('num');
         if ($id != 0) {
             $match = \Model_Match::find($id);
             if ($match) {
                 $match->vk_comments_count = $num;
                 $match->save();
                 return \View::forge('empty', array());
             }
         }
     }
 }
Example #3
0
 /**
  * Просмотр календаря матча конкретного сезона
  * 
  * @param int $season_id id сезона
  */
 public function action_view($season_id = NULL)
 {
     is_null($season_id) and \Response::redirect('');
     $matches = \Model_Match::find('all', array('related' => array('team_1', 'team_2', 'season'), 'where' => array(array('season_id', '=', $season_id)), 'order_by' => array('date' => 'ASC')));
     if ($matches) {
         $name = '';
         $res = array();
         foreach ($matches as $item) {
             if ($item->name != $name) {
                 $res[] = array('name' => $item->name, 'matches' => array());
                 $name = $item->name;
             }
             $res[count($res) - 1]['matches'][] = $item;
             if (!isset($season)) {
                 $season = $item->season->value;
             }
         }
         $this->template->page_title = 'Команда :: Календарь матчей :: ' . $season;
         $this->template->content = \View::forge('calendar/view', array('matches' => $res), FALSE);
     } else {
         \Response::redirect('');
     }
 }
Example #4
0
 public function action_delete($id = null)
 {
     is_null($id) and \Response::redirect('matches');
     if ($match = \Model_Match::find($id)) {
         $match->delete();
         \Session::set_flash('success', 'Матч удалён.');
     } else {
         \Session::set_flash('error', 'Could not delete match #' . $id);
     }
     \Response::redirect('admin/competitions/matches');
 }
Example #5
0
 /**
  * Действие для отображение предыдущего матча
  */
 public function action_previous_match()
 {
     $data['match'] = \Model_Match::query()->related(array('team_1', 'team_2', 'status'))->where_open()->where('team_1_id', \Config::get('main_team_id'))->or_where('team_2_id', \Config::get('main_team_id'))->where_close()->where('date', '<', time())->where('status_id', '=', 2)->order_by('date', 'DESC')->limit(1)->get_one();
     return \View::forge('widgets/previous_match', $data)->render();
 }