Esempio n. 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $hname = Auth::user();
     $rno = Input::get('room_no');
     $st = Carbon::createFromFormat('d-m-Y H:i', Input::get('starttime'));
     $et = Carbon::createFromFormat('d-m-Y H:i', Input::get('endtime'));
     $currbooking = RoomBook::where('room_no', $rno)->where('starttime', '<', $et)->where('endtime', '>', $st)->get();
     $otherinputs = Input::except(array('_token', 'starttime', 'endtime'));
     $otherinputs['starttime'] = $st;
     $otherinputs['endtime'] = $et;
     $evttype = Input::get('eventtype');
     $evtconfig = Config::get('roomconfig.event_types');
     $otherinputs['priority'] = $evtconfig[$evttype]['priority'];
     if (!count($currbooking)) {
         $otherinputs['status'] = 'C';
         RoomBook::saveFormData($otherinputs);
         return redirect('home');
     } else {
         $otherinputs['status'] = 'W';
         RoomBook::saveFormData($otherinputs);
         return redirect('home');
     }
     //		return ("room booked");
 }