コード例 #1
0
 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);
     }
 }
コード例 #2
0
 public function delete(Request $request)
 {
     $user = $request->session()->get('user');
     if (is_null($user)) {
         return false;
     }
     if ($request['id'] != null) {
         $buildings = buildingModel::where('id', '=', $request['id'])->delete();
         // delete facilities
         $buildingFacilities = buildingFacilityModel::where("buildingid", "=", $request['id'])->delete();
         //delete room
         //delete room facilities
         //delete room booking
         $rooms = roomModel::where("buildingID", "=", $request['id'])->get();
         foreach ($rooms as $room) {
             roomFacilityModel::where("roomid", "=", $room->id)->delete();
             roomBookingModel::where("roomid", "=", $room->id)->delete();
             $room->delete();
         }
         //delete packages
         $packages = packageModel::where("buildingid", "=", $request['id'])->delete();
         //delete booking
         //delete travel
         $bookings = bookingModel::where("buildingID", "=", $request['id'])->get();
         foreach ($bookings as $booking) {
             bookingPackageModel::where("booking_id", "=", $booking->id)->delete();
             travelModel::where("bookingID", "=", $booking->id)->delete();
             $booking->delete();
         }
     }
     print json_encode(array());
 }
コード例 #3
0
ファイル: RoomController.php プロジェクト: manvimal/lodgiify
 function deleteRoomFacility(Request $request)
 {
     $user = $request->session()->get('user');
     if (is_null($user)) {
         return false;
     }
     if ($request['id'] != null) {
         $deleteRoomFacility = roomFacilityModel::where('id', '=', $request['id'])->delete();
         return redirect()->action('LandlordController@addBuilding');
     }
     print json_encode(array(1));
 }