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');
     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;
 }
 function deleteBuildingFacility(Request $request)
 {
     $user = $request->session()->get('user');
     if (is_null($user)) {
         return false;
     }
     if ($request['id'] != null) {
         $deleteBuildingFacility = buildingFacilityModel::where('id', '=', $request['id'])->delete();
         return redirect()->action('LandlordController@addBuilding');
     }
     print json_encode(array(1));
 }