/** * 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'); } }
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)); }
/** * 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'); }
/** * @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); }