Ejemplo n.º 1
0
 public function postRegister()
 {
     $inputs = Input::all();
     $validator_owner = Validator::make($inputs, OwnerHotel::$rules);
     $validator_hotel = Validator::make($inputs, \App\Hotels::$roles);
     try {
         // create user owner
         $data = ['sure_name' => $inputs['sure_name'], 'role_id' => $inputs['role'], 'first_name' => $inputs['first_name'], 'last_name' => $inputs['last_name'], 'email' => $inputs['email'], 'password' => $inputs['password'] = Hash::make($inputs['password'])];
         $success_owner = OwnerHotel::create($data);
         if (!$success_owner) {
             throw new Exception('Can not create User owner !');
         }
         // create new hotel
         $hotelData = ['name_local' => $inputs['name_local'], 'owner_id' => $success_owner->id, 'num_of_rooms' => $inputs['num_of_rooms'], 'main_phone' => $inputs['main_phone'], 'hotel_website' => $inputs['hotel_website'], 'num_of_booking_month' => $inputs['num_of_booking_month'], 'license_number' => $inputs['license_number'], 'property_english' => $inputs['property_english']];
         $success_hotel = \App\Hotels::create($hotelData);
         if ($validator_owner->fails() || $validator_hotel->fails()) {
             $errors = $validator_hotel->messages()->merge($validator_owner->messages());
             return Redirect::back()->withErrors($errors)->withInput([$hotelData, $data]);
         }
         if (!$success_hotel) {
             throw new Exception('Can not create Hotel');
         }
         return Redirect::to('account/login')->with('alert-success', 'Sign up successful, Please check your email.');
     } catch (Exception $e) {
         return Redirect::back()->withInput()->withError('Can not create !');
     }
 }
Ejemplo n.º 2
0
 public function getAdd()
 {
     $getHotel = \App\Hotels::orderBy('hotel_name', 'ASC')->where('owner_id', Auth::user()->id)->lists('hotel_name', 'id');
     $getRoom = RoomType::orderBy('id', 'ASC')->lists('name', 'id');
     return View::make('room.add', compact('getHotel', 'getRoom'));
 }
Ejemplo n.º 3
0
 public function getHotels()
 {
     return Hotels::all();
 }