public function updateTimeServer($timeStamp, $userId, $type) { $time = Time::where('type', $type)->where('userId', $userId)->first(); if (is_null($time)) { Time::insert(array('type' => $type, 'userId' => $userId, 'time' => $timeStamp)); } else { Time::where('type', $type)->where('userId', $userId)->update(array('time' => $timeStamp)); } }
public function getTime($userId, $type, $timeStamp) { $time = Time::where('userId', $userId)->where('type', $type)->first(); if (is_null($time)) { Time::insert(array('userId' => $userId, 'type' => $type, 'time' => $timeStamp)); return array('status' => 306); } else { return array('status' => 200, 'result' => $time); } }