function testCreate() { // Given $this->startSession(); $userData = ['name' => 'Captain Kirk', 'email' => '*****@*****.**', 'password' => 'strongpassword', 'country_code' => '1', 'phone_number' => '5558180101']; $newUser = new User($userData); $newUser->save(); $this->be($newUser); $propertyData = ['description' => 'Some description', 'image_url' => 'http://www.someimage.com']; $newProperty = new VacationProperty($propertyData); $newUser->properties()->save($newProperty); $this->assertCount(0, Reservation::all()); $mockTwilioClient = Mockery::mock(Client::class)->makePartial(); $mockTwilioMessages = Mockery::mock(); $mockTwilioClient->messages = $mockTwilioMessages; $twilioNumber = config('services.twilio')['number']; $mockTwilioMessages->shouldReceive('create')->with($newUser->fullNumber(), ['from' => $twilioNumber, 'body' => 'Some reservation message - Reply \'yes\' or \'accept\' to confirm the reservation, or anything else to reject it.'])->once(); $this->app->instance(Client::class, $mockTwilioClient); // When $response = $this->call('POST', route('reservation-create', ['id' => $newProperty->id]), ['message' => 'Some reservation message', '_token' => csrf_token()]); // Then $this->assertCount(1, Reservation::all()); $reservation = Reservation::first(); $this->assertEquals($reservation->message, 'Some reservation message'); $this->assertRedirectedToRoute('property-show', ['id' => $newProperty->id]); $this->assertSessionHas('status'); $flashreservation = $this->app['session']->get('status'); $this->assertEquals($flashreservation, "Sending your reservation request now."); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker::create(); $reservations = Reservation::all(); $room = DB::table('room')->min('id'); foreach ($reservations as $reservation) { $reservedRoom = new ReservedRoom(); $reservedRoom->reservation_id = $reservation->id; $reservedRoom->room_id = $room; $reservedRoom->save(); $room = Room::where('id', '>', $room)->min('id'); } }
public function index(Request $request) { $reservations = null; if ($request->input('with_locators')) { $reservations = Reservation::with('locator')->get(); } else { if ($request->input('for_locator') !== null) { $reservations = Reservation::with('locator')->where('locator_id', '=', $request->input('for_locator'))->get(); } else { $reservations = Reservation::all(); } } foreach ($reservations as $reservation) { $reservation['since'] = date("Y-m-d\\TH:i:s.000\\Z", strtotime($reservation['since'])); $reservation['till'] = date("Y-m-d\\TH:i:s.000\\Z", strtotime($reservation['till'])); } return response()->json($reservations); }
public function index() { $reservations = Reservation::all(); return view('admin.reservations', ['reservations' => $reservations]); }
/** * Display a listing of the resource. * GET /reservation * * @return Response */ public function index() { // return Reservation::all(); }
/** * Display a listing of the reservation. * * @return Response */ public function index() { $reservations = Reservation::all(); return view('admin.reservations.index', compact('reservations')); }