예제 #1
0
 /**
  * Store a newly created resource in storage.
  * POST|/booking|store|booking.store
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('user_id' => 'required|numeric', 'track_id' => 'required|numeric');
     $validator = \Validator::make(\Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return \Redirect::to('booking/create')->withErrors($validator)->withInput();
     } else {
         $booking = new \Trails\Models\Booking();
         $booking->user_id = \Input::get('user_id');
         $booking->track_id = \Input::get('track_id');
         $booking->save();
         \Session::flash('message', 'Successfully created booking!');
         return \Redirect::to('booking');
     }
 }
예제 #2
0
 public function run()
 {
     Eloquent::unguard();
     DB::table('bookings')->truncate();
     Booking::create(array('user_id' => 1, 'track_id' => 3));
     Booking::create(array('user_id' => 1, 'track_id' => 2));
     Booking::create(array('user_id' => 1, 'track_id' => 1));
     Booking::create(array('user_id' => 2, 'track_id' => 1));
     Booking::create(array('user_id' => 2, 'track_id' => 2));
 }
예제 #3
0
 /**
  * Remove the specified resource from storage.
  * DELETE|/booking/{id}|destroy|booking.destroy
  *
  * @param int $id
  * @return Response
  */
 public function destroy($id)
 {
     $booking = \Trails\Models\Booking::find($id);
     $booking->delete();
     \Session::flash('message', 'Successfully deleted booking!');
     return \Redirect::to('booking');
 }
예제 #4
0
 /**
  * @test
  * @large
  */
 public function testTrack()
 {
     $booking = Booking::find(1);
     $assert = $booking->track;
     $this->assertInstanceOf('Trails\\Models\\Track', $assert);
     $this->assertEquals(3, $assert->id);
     $this->assertEquals('A planned session', $assert->name);
     $this->assertEquals(TrackStatus::PLANNED, $assert->status);
     $this->assertEquals('Very very planned!', $assert->description);
 }