Example #1
0
     $features->family_kid_friendly = on2true($request->get('family_kid_friendly', false));
     $features->suitable_for_events = on2true($request->get('suitable_for_events', false));
     $features->smoking_allowed = on2true($request->get('smoking_allowed', false));
     $features->wheelchair_accessible = on2true($request->get('wheelchair_accessible', false));
     $features->elevator_in_building = on2true($request->get('elevator_in_building', false));
     $features->indoor_fireplace = on2true($request->get('indoor_fireplace', false));
     $features->buzzer_wireless_intercom = on2true($request->get('buzzer_wireless_intercom', false));
     $features->doorman = on2true($request->get('doorman', false));
     $features->pool = on2true($request->get('pool', false));
     $features->hot_tub = on2true($request->get('hot_tub', false));
     $features->gym = on2true($request->get('gym', false));
     $features->feature_24_hour_check_in = on2true($request->get('feature_24_hour_check_in', false));
     $features->hangers = on2true($request->get('hangers', false));
     $features->iron = on2true($request->get('iron', false));
     $features->hair_dryer = on2true($request->get('hair_dryer', false));
     $features->laptop_friendly_workspace = on2true($request->get('laptop_friendly_workspace', false));
     $features->save();
     return redirect(url('/property/edit/' . $data['property_id']));
 });
 Route::get('/profile', array('middleware' => 'auth', function () {
     $user = User::find(Auth::id());
     $degrees = \App\Degree::where('user_id', $user->id)->orderBy('id', 'asc')->get();
     $num_degree_str = ['one', 'two', 'three', 'four'];
     for ($i = 0; $i < $user->number_of_degrees; $i++) {
         $user['degree_year_' . $num_degree_str[$i]] = $degrees[$i]->year;
         $user['degree_faculty_' . $num_degree_str[$i]] = $degrees[$i]->faculty;
         $user['degree_type_' . $num_degree_str[$i]] = $degrees[$i]->type;
     }
     return view('my_profile', ['user' => $user]);
 }));
 Route::delete('/profile', array('middleware' => 'auth', function (Request $request) {
 public function searchPlaces(Request $request)
 {
     $data = $request->all();
     $properties = DB::table('properties')->where('owner_id', '!=', Auth::id());
     if ($request->has('city')) {
         $city = City::where('name', $data['city'])->first();
         $properties = $properties->where('city_id', '=', $city->id);
     }
     if ($request->has('district')) {
         $district = District::where('name', $data['district'])->first();
         $properties = $properties->where('district_id', '=', $district->id);
     }
     if ($request->has('type')) {
         $properties = $properties->where('type', '=', $data['type']);
     }
     if ($request->has('min_occupancy')) {
         $properties = $properties->where('max_occupancy', '>=', $data['min_occupancy']);
     }
     if ($request->has('max_occupancy')) {
         $properties = $properties->where('max_occupancy', '<=', $data['max_occupancy']);
     }
     if ($request->has('min_price_per_night')) {
         $properties = $properties->where('price_per_night', '>=', $data['min_price_per_night']);
     }
     if ($request->has('max_price_per_night')) {
         $properties = $properties->where('price_per_night', '<=', $data['max_price_per_night']);
     }
     $properties = $properties->join('property_features', 'properties.id', '=', 'property_features.property_id');
     if ($request->has('kitchen')) {
         $properties = $properties->where('kitchen', '=', on2true($data['kitchen']));
     }
     if ($request->has('internet')) {
         $properties = $properties->where('internet', '=', on2true($data['internet']));
     }
     if ($request->has('tv')) {
         $properties = $properties->where('tv', '=', on2true($data['tv']));
     }
     if ($request->has('essentials')) {
         $properties = $properties->where('essentials', '=', on2true($data['essentials']));
     }
     if ($request->has('shampoo')) {
         $properties = $properties->where('shampoo', '=', on2true($data['shampoo']));
     }
     if ($request->has('heating')) {
         $properties = $properties->where('heating', '=', on2true($data['heating']));
     }
     if ($request->has('air_conditioning')) {
         $properties = $properties->where('air_conditioning', '=', on2true($data['air_conditioning']));
     }
     if ($request->has('washer')) {
         $properties = $properties->where('washer', '=', on2true($data['washer']));
     }
     if ($request->has('dryer')) {
         $properties = $properties->where('dryer', '=', on2true($data['dryer']));
     }
     if ($request->has('free_parking_on_premises')) {
         $properties = $properties->where('free_parking_on_premises', '=', on2true($data['free_parking_on_premises']));
     }
     if ($request->has('wireless_internet')) {
         $properties = $properties->where('wireless_internet', '=', on2true($data['wireless_internet']));
     }
     if ($request->has('cable_tv')) {
         $properties = $properties->where('cable_tv', '=', on2true($data['cable_tv']));
     }
     if ($request->has('breakfast')) {
         $properties = $properties->where('breakfast', '=', on2true($data['breakfast']));
     }
     if ($request->has('pets_allowed')) {
         $properties = $properties->where('pets_allowed', '=', on2true($data['pets_allowed']));
     }
     if ($request->has('family_kid_friendly')) {
         $properties = $properties->where('family_kid_friendly', '=', on2true($data['family_kid_friendly']));
     }
     if ($request->has('suitable_for_events')) {
         $properties = $properties->where('suitable_for_events', '=', on2true($data['suitable_for_events']));
     }
     if ($request->has('smoking_allowed')) {
         $properties = $properties->where('smoking_allowed', '=', on2true($data['smoking_allowed']));
     }
     if ($request->has('wheelchair_accessible')) {
         $properties = $properties->where('wheelchair_accessible', '=', on2true($data['wheelchair_accessible']));
     }
     if ($request->has('elevator_in_building')) {
         $properties = $properties->where('elevator_in_building', '=', on2true($data['elevator_in_building']));
     }
     if ($request->has('indoor_fireplace')) {
         $properties = $properties->where('indoor_fireplace', '=', on2true($data['indoor_fireplace']));
     }
     if ($request->has('buzzer_wireless_intercom')) {
         $properties = $properties->where('buzzer_wireless_intercom', '=', on2true($data['buzzer_wireless_intercom']));
     }
     if ($request->has('doorman')) {
         $properties = $properties->where('doorman', '=', on2true($data['doorman']));
     }
     if ($request->has('pool')) {
         $properties = $properties->where('pool', '=', on2true($data['pool']));
     }
     if ($request->has('hot_tub')) {
         $properties = $properties->where('hot_tub', '=', on2true($data['hot_tub']));
     }
     if ($request->has('gym')) {
         $properties = $properties->where('gym', '=', on2true($data['gym']));
     }
     if ($request->has('feature_24_hour_check_in')) {
         $properties = $properties->where('feature_24_hour_check_in', '=', on2true($data['feature_24_hour_check_in']));
     }
     if ($request->has('hangers')) {
         $properties = $properties->where('hangers', '=', on2true($data['hangers']));
     }
     if ($request->has('iron')) {
         $properties = $properties->where('iron', '=', on2true($data['iron']));
     }
     if ($request->has('hair_dryer')) {
         $properties = $properties->where('hair_dryer', '=', on2true($data['hair_dryer']));
     }
     if ($request->has('laptop_friendly_workspace')) {
         $properties = $properties->where('laptop_friendly_workspace', '=', on2true($data['laptop_friendly_workspace']));
     }
     $properties = $properties->get();
     foreach ($properties as $property) {
         $property->id = $property->property_id;
         $property->city_name = City::find($property->city_id)->name;
         $photo_ids = PropertyPictureBridge::where('property_id', $property->id)->get();
         if (count($photo_ids) < 1) {
             $property->image_url = env('PLACEHOLDER_IMAGE_URL');
         } else {
             $property->image_url = Picture::find($photo_ids[0]->picture_id)->url;
         }
     }
     $cities = City::all();
     return redirect(url('/places/searchresult'))->with(['properties' => $properties, 'cities' => $cities]);
 }