コード例 #1
0
 public function postAdd()
 {
     $inputs = Input::all();
     DB::beginTransaction();
     try {
         $room = new Rooms();
         $data = array('name' => $inputs['roomName'], 'hotel_id' => $inputs['hotelID'], 'room_type_id' => $inputs['roomTypeID'], 'floors' => $inputs['floors'], 'buildings' => $inputs['building'], 'description' => $inputs['description']);
         $create = $room->create($data);
         if (!$create) {
             throw new Exception('Can not create room at this time');
         }
         DB::commit();
         return Redirect::to('room')->withSuccess('Data has been created successful !');
     } catch (Exception $e) {
         dd($e->getMessage());
         DB::rollback();
         return Redirect::back()->withInput()->withError('Count not been created !');
     }
 }