Beispiel #1
0
 public function rentRoomVehicles(Request $request)
 {
     $user = $request->session()->get('user');
     if (is_null($user)) {
         return redirect()->action('MainController@index');
     } else {
         if ($user[0]->type == 'tenant') {
             //Gets building categories
             $buildingCategories = buildingCategory::all();
             //	$buildings = buildingModel::where('landlordID', '=', $user[0]->ID)->get();
             //return view('pages.landlordAddBuilding',  array('categories' => $categories,'user' => $user, 'buildings' => $buildings));
             //Gets buildings
             $buildings = buildingModel::where('created_at', '!=', '')->orderBy('created_at', 'DESC')->get();
             $buildingFacAr = array();
             foreach ($buildings as $building) {
                 //$buildingFacilities = buildingFacilityModel::where('buildingid', '=', $building->id)->get();
                 $buildingFacilities = buildingFacilityModel::where('buildingid', '=', $building->id)->get();
                 array_push($buildingFacAr, $buildingFacilities);
             }
             $Facilities = facilityModel::all();
             //return view('pages.landlordbuildings',  array('user' => $user, 'buildings' => $buildings));
             return view('pages.bestDeals', array('user' => $user, 'Facilities' => $Facilities, 'buildings' => $buildings, 'buildingCategories' => $buildingCategories, 'buildingFacilities' => $buildingFacAr));
         } else {
             return response()->view('pages.404', ['user' => $user], 404);
         }
     }
 }
 public function addBuilding(Request $request)
 {
     $user = $request->session()->get('user');
     //Gets building categories
     $categories = buildingCategory::all();
     $buildings = buildingModel::where('landlordID', '=', $user[0]->ID)->get();
     return view('pages.landlordAddBuilding', array('categories' => $categories, 'user' => $user, 'buildings' => $buildings));
 }
 public function register(Request $request)
 {
     $user = $request->session()->get('user');
     $categories = buildingCategory::all();
     if (isset($request['buildingName']) && !empty($request['buildingName'])) {
         $buildingName = $request['buildingName'];
     }
     if (isset($request['lattitude']) && !empty($request['lattitude'])) {
         $lattitude = $request['lattitude'];
     }
     if (isset($request['longitude']) && !empty($request['longitude'])) {
         $longitude = $request['longitude'];
     }
     if (isset($request['category']) && !empty($request['category'])) {
         $category = $request['category'];
     }
     if (isset($request['location']) && !empty($request['location'])) {
         $location = $request['location'];
     }
     if (isset($request['desc']) && !empty($request['desc'])) {
         $desc = $request['desc'];
     }
     $uploadMsg = "";
     $fileName = '';
     if (RequestStatic::hasFile('image') && RequestStatic::file('image')->isValid()) {
         $extension = Input::file('image')->getClientOriginalExtension();
         // getting image extension
         $fileName = rand(11111, 99999) . '.' . $extension;
         // renameing image
         $name = $this->destinationPath;
         RequestStatic::file('image')->move($name, $fileName);
     }
     // Retrieve user session
     $user = $request->session()->get('user');
     //Save building for user
     $building = new buildingModel();
     $building->buildingName = $buildingName;
     $building->lattitude = $lattitude;
     $building->longitude = $longitude;
     $building->buildingLocation = $location;
     $building->buildingCatId = $category;
     $building->landlordID = $user[0]->ID;
     $building->desc = $desc;
     $building->image = $fileName;
     $building->save();
     Session::flash('success', 'Building successfully registered');
     return Redirect::to('addBuilding');
 }
 public function addBuilding(Request $request)
 {
     $user = $request->session()->get('user');
     if (is_null($user)) {
         return redirect()->action('MainController@index');
     } elseif ($user[0]->type == 'Landlord') {
         //Gets building categories
         $categories = buildingCategory::all();
         $buildings = buildingModel::where('landlordID', '=', $user[0]->id)->get();
         $hasBuildings = buildingModel::where('landlordID', '=', $user[0]->id)->get();
         $facilities = facilityModel::all();
         $buildingFacAr = array();
         foreach ($buildings as $building) {
             $buildingFacilities = buildingFacilityModel::where('buildingid', '=', $building->id)->get();
             array_push($buildingFacAr, $buildingFacilities);
         }
         return view('pages.landlordAddBuilding', array('categories' => $categories, 'buildingFacilities' => $buildingFacAr, 'user' => $user, 'buildings' => $buildings, 'facilities' => $facilities, 'hasBuildings' => $hasBuildings));
     } else {
         return response()->view('pages.404', ['user' => $user], 404);
     }
     //var_dump($buildings);
     //die;
 }
 public function register(Request $request)
 {
     $user = $request->session()->get('user');
     $error = false;
     if (is_null($user)) {
         return redirect()->action('MainController@index');
     } elseif ($user[0]->type == "Landlord") {
         $categories = buildingCategory::all();
         if (isset($request['buildingName']) && !empty($request['buildingName'])) {
             $buildingName = $request['buildingName'];
         } else {
             $error = true;
         }
         if (isset($request['lattitude']) && !empty($request['lattitude'])) {
             $lattitude = $request['lattitude'];
         } else {
             $error = true;
         }
         if (isset($request['longitude']) && !empty($request['longitude'])) {
             $longitude = $request['longitude'];
         } else {
             $error = true;
         }
         if (isset($request['category']) && !empty($request['category'])) {
             $category = $request['category'];
         } else {
             $error = true;
         }
         if (isset($request['location']) && !empty($request['location'])) {
             $location = $request['location'];
         }
         if (isset($request['desc']) && !empty($request['desc'])) {
             $desc = $request['desc'];
         } else {
             $error = true;
         }
         if (isset($request['facilityCheckboxes']) && !empty($request['facilityCheckboxes'])) {
             $facilityCheckboxes = $request['facilityCheckboxes'];
         } else {
             $facilityCheckboxes = '';
             $error = true;
         }
         $uploadMsg = "";
         $fileName = '';
         if (RequestStatic::hasFile('image') && RequestStatic::file('image')->isValid()) {
             $extension = Input::file('image')->getClientOriginalExtension();
             // getting image extension
             $fileName = rand(11111, 99999) . '.' . $extension;
             // renameing image
             $name = $this->destinationPath;
             RequestStatic::file('image')->move($name, $fileName);
         } else {
             $fileName = 'nopreview.jpg';
         }
         if ($error == false) {
             // Retrieve user session
             $user = $request->session()->get('user');
             //Save building for user
             $building = new buildingModel();
             $building->buildingName = $buildingName;
             $building->lattitude = $lattitude;
             $building->longitude = $longitude;
             $building->buildingLocation = $location;
             $building->buildingCatId = $category;
             $building->landlordID = $user[0]->id;
             $building->desc = $desc;
             $building->image = $fileName;
             $building->save();
             Session::flash('success', 'Building successfully registered');
             foreach ($facilityCheckboxes as $facilityCheckbox) {
                 $facility = new buildingFacilityModel();
                 $facility->facilityid = $facilityCheckbox;
                 $facility->buildingid = $building->id;
                 $facility->save();
                 //var_dump($facilityCheckboxes[0]);
             }
         }
         return Redirect::to('addBuilding');
     } else {
         return response()->view('pages.404', ['user' => $user], 404);
     }
 }