public function addRoom(Request $request) { $user = $request->session()->get('user'); if (is_null($user)) { return redirect()->action('MainController@index'); } elseif ($user[0]->type == 'Landlord') { //Gets room categories $categories = roomCategory::all(); //Gets buildings $buildings = buildingModel::where('landlordID', '=', $user[0]->id)->get(); $facilities = facilityModel::all(); //Get rooms $rooms = roomModel::where('landlordID', '=', $user[0]->id)->get(); $AddRoomFacilities = roomModel::where('landlordID', '=', $user[0]->id)->get(); $roomFacAr = array(); foreach ($rooms as $room) { $roomFacilities = roomFacilityModel::where('roomid', '=', $room->id)->get(); // array_push($roomFacAr, $roomFacilities); } return view('pages.landlordAddRoom', array('categories' => $categories, 'user' => $user, 'roomFacilities' => $roomFacAr, 'buildings' => $buildings, 'facilities' => $facilities, 'rooms' => $rooms, 'AddRoomFacilities' => $AddRoomFacilities)); } else { return response()->view('pages.404', ['user' => $user], 404); } }
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); } } }
function addRoomFacility(Request $request) { $user = $request->session()->get('user'); if (is_null($user)) { return false; } $error = 1; $messge = array(); if (isset($_REQUEST['ddlAddRoomFacility']) && !empty($_REQUEST['ddlAddRoomFacility'])) { $ddlAddRoomFacility = $_REQUEST['ddlAddRoomFacility']; } if (isset($_REQUEST['AddfacilityCheckboxes']) && !empty($_REQUEST['AddfacilityCheckboxes'])) { $AddfacilityCheckboxes = $_REQUEST['AddfacilityCheckboxes']; } $roomFacilities = roomFacilityModel::where('roomid', '=', $ddlAddRoomFacility)->get(); $facilities = array(); foreach ($AddfacilityCheckboxes as $facilityCheckbox) { $messgeTmp = array(); $facilityExists = $this->checkFacilityExists($roomFacilities, $facilityCheckbox); if (!empty($roomFacilities) && $facilityExists[0]) { $messgeTmp['status'] = -1; $messgeTmp['msg'] = $facilityExists[1] . " facility Already exists"; } else { $facility = new roomFacilityModel(); $facility->facilityid = $facilityCheckbox; $facility->roomid = $ddlAddRoomFacility; $facility->save(); $room = roomModel::where('id', '=', $ddlAddRoomFacility)->get(); $fac = facilityModel::where('id', '=', $facilityCheckbox)->get(); $facility['facility'] = $fac; $facility['room'] = $room; $messgeTmp['status'] = 1; $messgeTmp['msg'] = "Facility Successfully added"; $messgeTmp['facility'] = $facility; //return redirect()->action('LandlordController@addRoom'); array_push($facilities, $facility); } array_push($messge, $messgeTmp); } echo json_encode($messge); }