Пример #1
0
 public function action_create()
 {
     if (Input::method() == 'POST') {
         $val = Model_User_Station_History::validate('create');
         if ($val->run()) {
             $user_station_history = Model_User_Station_History::forge(array('railway_id' => Input::post('railway_id'), 'station_id' => Input::post('station_id'), 'user_id' => Input::post('user_id')));
             if ($user_station_history and $user_station_history->save()) {
                 Session::set_flash('success', 'Added user_station_history #' . $user_station_history->id . '.');
                 Response::redirect('user/station/history');
             } else {
                 Session::set_flash('error', 'Could not save user_station_history.');
             }
         } else {
             Session::set_flash('error', $val->error());
         }
     }
     $this->template->title = "User_Station_Histories";
     $this->template->content = View::forge('user/station/history/create');
 }
Пример #2
0
 public function post_save_now_station()
 {
     $state = Model_Userstate::find($this->_user->id);
     if ($station_id = Input::post('from_station_id')) {
         $list = explode('.', $station_id);
         if (!empty($list[2]) || isset($list[2])) {
             $railway_id = $list[0] . '.' . $list[1];
             $history = Model_User_Station_History::find('first', ['where' => [['user_id', '=', $this->_user->id], ['station_id', '=', $station_id]]]);
             if (empty($history)) {
                 $history = Model_User_Station_History::forge(['user_id' => $this->_user->id, 'station_id' => $station_id, 'railway_id' => $railway_id]);
                 $history->save();
             }
         }
         $state->now_station_id = $station_id;
         $state->save();
         $this->response(['success' => 'ok']);
     } else {
         $this->response(['error' => 'invalid save']);
     }
 }