/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //
     $reservationValidator = new ReservationValidator();
     $reservationRepository = new ReservationRepository(new ReservationStore());
     $reserveObject = new Reservation();
     if ($reservationValidator->validate($this->start_date, $this->end_date, $this->rooms)) {
         $reservation = $reservationRepository->create(array('date_start' => $this->start_date, 'date_end' => $this->end_date, 'rooms' => $this->rooms, 'user_id' => $this->user->id));
         $reserveObject = $reservation;
     }
     event(new RoomWasReserved($this->user, $reserveObject));
 }
 public function testReservationRoomExample()
 {
     $reservationRepo = new ReservationRepository(new ReservationStore());
     $start_date = '2015-10-01';
     $end_date = '2015-10-10';
     $user_id = App\User::first()->id;
     $rooms = Room::take(2)->lists('id')->toArray();
     $reservation = $reservationRepo->create(['date_start' => $start_date, 'date_end' => $end_date, 'rooms' => $rooms, 'reservation_number' => '0001', 'user_id' => $user_id]);
     $this->assertInstanceOf('App\\Reservation', $reservation);
     $this->assertEquals('2015-10-01', $reservation->date_start);
     $this->assertEquals(2, count($reservation->rooms));
 }
 /**
  * Store a newly created resource in storage.
  * POST /reservation
  *
  * @return Response
  */
 public function store()
 {
     //
     $reservationRepository = new ReservationRepository(new ReservationStore());
     $reservationValidator = new ReservationValidator();
     if ($reservationValidator->validate(\Input::get('start_date'), \Input::get('end_date'), \Input::get('rooms'))) {
         $reservationRepository->create(['date_start' => \Input::get('start_date'), 'date_end' => \Input::get('end_date'), 'rooms' => \Input::get('rooms'), 'user_id' => \Input::get('user_id')]);
     }
     $user = User::find(\Input::get('user_id'));
     $start_date = \Input::get('start_date');
     $end_date = \Input::get('end_date');
     $rooms = \Input::get('rooms');
     $roomAvailable = 1;
     if ($roomAvailable) {
         $this->dispatch(new ReserveRoomJob($user, $start_date, $end_date, $rooms));
     } else {
         $this->dispatch(new PlaceOnWaitingList($user, $start_date, $end_date, $rooms));
     }
 }