public function verifyAppointment() { $otp = Input::get('otp'); $email = Input::get('email'); $phone = Input::get('phone'); try { $appointment = Appointment::where('otp', '=', $otp)->where('email', '=', $email)->where('phone', '=', $phone)->firstOrFail(); $appointment->verified = 1; $appointment->save(); return Response::data($appointment); } catch (ModelNotFoundException $e) { return Response::invalid(); } }
public function login() { $email = Input::get('email'); $phone = Input::get('phone'); $otp = $this->generateOtp(); try { $user = User::where('email', '=', $email)->where('phone', '=', $phone)->firstOrFail(); $user->otp = $otp; $user->save(); return Response::data($user); } catch (ModelNotFoundException $e) { // Create user $user = User::create(['email' => $email, 'phone' => $phone, 'otp' => $otp]); return Response::data($user); } }
public function showAllSpecializations() { $s = Specialization::all(); return Response::data($s); }
public function index() { $clinics = Clinic::all(); return Response::data($clinics); }
public function testResponseJson() { $arr = array('test' => 't1'); $response = new Response($arr, Response::HTTP_OK, new DataJson()); $this->assertJsonStringEqualsJsonString(json_encode($arr), $response->data()); }
include '../vendor/autoload.php'; // set true for testing purposes $linear = false; $response = new Response(); try { if (!array_key_exists('start', $_GET)) { throw new \RuntimeException('No start time specified.'); } if (!array_key_exists('end', $_GET)) { throw new \RuntimeException('No end time specified.'); } if (!array_key_exists('step', $_GET)) { throw new \RuntimeException('No step specified.'); } $start = (int) $_GET['start']; $end = (int) $_GET['end']; $step = (int) $_GET['step']; // 30m if ($linear) { $bandwidth = new Linear($start, $end, $step); } elseif ($_GET['weak']) { $bandwidth = new Bandwidth(0, 2400, 2000, 386, 0.05); } else { $bandwidth = new Bandwidth(0, 12000, 8000, 1024, 0.05); } $response->data('datapoints', $bandwidth->get($start, $end, $step)); } catch (\Exception $e) { $response->addError($e->getMessage()); } echo $response->toJson();