Exemple #1
0
 public function get_station_history()
 {
     $histories = Model_User_Station_History::get_history($this->_user->id);
     if (empty($histories)) {
         $this->response($this->_error('情報がありません'), 200);
         return;
     }
     $this->response(['success' => true, 'data' => $histories], 200);
 }
Exemple #2
0
 public function action_delete($id = null)
 {
     is_null($id) and Response::redirect('user/station/history');
     if ($user_station_history = Model_User_Station_History::find($id)) {
         $user_station_history->delete();
         Session::set_flash('success', 'Deleted user_station_history #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete user_station_history #' . $id);
     }
     Response::redirect('user/station/history');
 }
Exemple #3
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']);
     }
 }