Example #1
0
 public function doEditAd()
 {
     $input = \Input::all();
     //input 'corrections'
     if (isset($input['door'])) {
         if ($input['door'] == '0') {
             $input['door'] = $input['door_letter'];
         } else {
             if ($input['door'] == '1') {
                 $input['door'] = $input['door_number'];
             }
         }
     }
     if (isset($input['has_booking'])) {
         if ($input['has_booking'] == '1') {
             $input['booking'] = $input['booking-percentage'];
         } else {
             if ($input['has_booking'] == '2') {
                 $input['booking'] = $input['booking-euros'];
             }
         }
     }
     if (isset($input['has_deposit'])) {
         if ($input['has_deposit'] == '1') {
             $input['deposit'] = $input['deposit-percentage'];
         } else {
             if ($input['has_deposit'] == '2') {
                 $input['deposit'] = $input['deposit-euros'];
             }
         }
     }
     //Find old Ad
     $Ad = Ad::findOrFail($input['ad_id']);
     //Delete old pics
     if ($Ad->pics->count()) {
         $Ad->pics()->delete();
     }
     //Associate new pictures with the Ad
     foreach ($input as $key => $value) {
         $exp_key = explode('_', $key);
         if ($exp_key[0] == 'pictures') {
             $pictures[] = ['filename' => $value];
         }
     }
     if (isset($pictures)) {
         foreach ($pictures as $picture) {
             AdPic::create(['filename' => $picture['filename'], 'ad_id' => $input['ad_id']]);
         }
     }
     //Save the new info
     switch ($input['operation']) {
         case '0':
             //sell
             switch ($input['typology']) {
                 case '0':
                     //apartment
                     $old = SellApartment::find($input['local_id']);
                     $old->price = $input['price'];
                     $old->community_cost = $input['community_cost'];
                     $old->is_bank_agency = isset($input['is_bank_agency']) && $input['is_bank_agency'] ? true : false;
                     $old->is_state_subsidized = isset($input['is_state_subsidized']) && $input['is_state_subsidized'] ? true : false;
                     $old->is_new_development = isset($input['is_new_development']) && $input['is_new_development'] ? true : false;
                     $old->is_new_development_finished = isset($input['is_new_development_finished']) && $input['is_new_development_finished'] ? true : false;
                     $old->is_rent_to_own = isset($input['is_rent_to_own']) && $input['is_rent_to_own'] ? true : false;
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->floor_number = $input['floor_number'];
                     $old->is_last_floor = isset($input['is_last_floor']) && $input['is_last_floor'] ? true : false;
                     $old->door = $input['door'];
                     $old->has_block = isset($input['has_block']) && $input['has_block'] ? true : false;
                     $old->block = isset($input['has_block']) && $input['has_block'] && isset($input['block']) ? $input['block'] : null;
                     $old->residential_area = $input['residential_area'];
                     $old->is_regular = isset($input['is_regular']) && $input['is_regular'] ? true : false;
                     $old->is_penthouse = isset($input['is_penthouse']) && $input['is_penthouse'] ? true : false;
                     $old->is_duplex = isset($input['is_duplex']) && $input['is_duplex'] ? true : false;
                     $old->is_studio = isset($input['is_studio']) && $input['is_studio'] ? true : false;
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->n_bedrooms = $input['n_bedrooms'];
                     $old->n_bathrooms = $input['n_bathrooms'];
                     $old->is_exterior = isset($input['is_exterior']) && $input['is_exterior'] ? true : false;
                     $old->has_elevator = isset($input['has_elevator']) && $input['has_elevator'] ? true : false;
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->faces_north = isset($input['faces_north']) && $input['faces_north'] ? true : false;
                     $old->faces_south = isset($input['faces_south']) && $input['faces_south'] ? true : false;
                     $old->faces_east = isset($input['faces_east']) && $input['faces_east'] ? true : false;
                     $old->faces_west = isset($input['faces_west']) && $input['faces_west'] ? true : false;
                     $old->has_builtin_closets = isset($input['has_builtin_closets']) && $input['has_builtin_closets'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_terrace = isset($input['has_terrace']) && $input['has_terrace'] ? true : false;
                     $old->has_box_room = isset($input['has_box_room']) && $input['has_box_room'] ? true : false;
                     $old->has_parking_space = isset($input['has_parking_space']) && $input['has_parking_space'] ? true : false;
                     $old->has_swimming_pool = isset($input['has_swimming_pool']) && $input['has_swimming_pool'] ? true : false;
                     $old->has_garden = isset($input['has_garden']) && $input['has_garden'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '1':
                     //house
                     $old = SellHouse::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->community_cost = $input['community_cost'];
                     $old->is_bank_agency = isset($input['is_bank_agency']) && $input['is_bank_agency'] ? true : false;
                     $old->is_state_subsidized = isset($input['is_state_subsidized']) && $input['is_state_subsidized'] ? true : false;
                     $old->is_new_development = isset($input['is_new_development']) && $input['is_new_development'] ? true : false;
                     $old->is_new_development_finished = isset($input['is_new_development_finished']) && $input['is_new_development_finished'] ? true : false;
                     $old->is_rent_to_own = isset($input['is_rent_to_own']) && $input['is_rent_to_own'] ? true : false;
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->residential_area = $input['residential_area'];
                     $old->category_house_id = $input['category_house_id'];
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->area_land = $input['area_land'];
                     $old->n_floors = $input['n_floors'];
                     $old->n_bedrooms = $input['n_bedrooms'];
                     $old->n_bathrooms = $input['n_bathrooms'];
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->faces_north = isset($input['faces_north']) && $input['faces_north'] ? true : false;
                     $old->faces_south = isset($input['faces_south']) && $input['faces_south'] ? true : false;
                     $old->faces_east = isset($input['faces_east']) && $input['faces_east'] ? true : false;
                     $old->faces_west = isset($input['faces_west']) && $input['faces_west'] ? true : false;
                     $old->has_builtin_closets = isset($input['has_builtin_closets']) && $input['has_builtin_closets'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_terrace = isset($input['has_terrace']) && $input['has_terrace'] ? true : false;
                     $old->has_box_room = isset($input['has_box_room']) && $input['has_box_room'] ? true : false;
                     $old->has_parking_space = isset($input['has_parking_space']) && $input['has_parking_space'] ? true : false;
                     $old->has_swimming_pool = isset($input['has_swimming_pool']) && $input['has_swimming_pool'] ? true : false;
                     $old->has_garden = isset($input['has_garden']) && $input['has_garden'] ? true : false;
                     $old->has_fireplace = isset($input['has_fireplace']) && $input['has_fireplace'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '2':
                     //country house
                     $old = SellCountryHouse::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->community_cost = $input['community_cost'];
                     $old->is_bank_agency = isset($input['is_bank_agency']) && $input['is_bank_agency'] ? true : false;
                     $old->is_state_subsidized = isset($input['is_state_subsidized']) && $input['is_state_subsidized'] ? true : false;
                     $old->is_new_development = isset($input['is_new_development']) && $input['is_new_development'] ? true : false;
                     $old->is_new_development_finished = isset($input['is_new_development_finished']) && $input['is_new_development_finished'] ? true : false;
                     $old->is_rent_to_own = isset($input['is_rent_to_own']) && $input['is_rent_to_own'] ? true : false;
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->residential_area = $input['residential_area'];
                     $old->category_country_house_id = $input['category_country_house_id'];
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->area_land = $input['area_land'];
                     $old->n_floors = $input['n_floors'];
                     $old->n_bedrooms = $input['n_bedrooms'];
                     $old->n_bathrooms = $input['n_bathrooms'];
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->faces_north = isset($input['faces_north']) && $input['faces_north'] ? true : false;
                     $old->faces_south = isset($input['faces_south']) && $input['faces_south'] ? true : false;
                     $old->faces_east = isset($input['faces_east']) && $input['faces_east'] ? true : false;
                     $old->faces_west = isset($input['faces_west']) && $input['faces_west'] ? true : false;
                     $old->has_builtin_closets = isset($input['has_builtin_closets']) && $input['has_builtin_closets'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_terrace = isset($input['has_terrace']) && $input['has_terrace'] ? true : false;
                     $old->has_box_room = isset($input['has_box_room']) && $input['has_box_room'] ? true : false;
                     $old->has_parking_space = isset($input['has_parking_space']) && $input['has_parking_space'] ? true : false;
                     $old->has_swimming_pool = isset($input['has_swimming_pool']) && $input['has_swimming_pool'] ? true : false;
                     $old->has_garden = isset($input['has_garden']) && $input['has_garden'] ? true : false;
                     $old->has_fireplace = isset($input['has_fireplace']) && $input['has_fireplace'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '3':
                     //office
                     $old = SellOffice::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->community_cost = $input['community_cost'];
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->floor_number = $input['floor_number'];
                     $old->door = $input['door'];
                     $old->has_block = isset($input['has_block']) && $input['has_block'] ? true : false;
                     $old->block = isset($input['has_block']) && $input['has_block'] && isset($input['block']) ? $input['block'] : null;
                     $old->residential_area = $input['residential_area'];
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->area_min_for_sale = $input['area_min_for_sale'];
                     $old->n_floors = $input['n_floors'];
                     $old->has_offices_only = isset($input['has_offices_only']) && $input['has_offices_only'] ? true : false;
                     $old->office_distribution_id = $input['office_distribution_id'];
                     $old->n_restrooms = $input['n_restrooms'];
                     $old->has_bathrooms = isset($input['has_bathrooms']) && $input['has_bathrooms'] ? true : false;
                     $old->has_bathrooms_inside = isset($input['has_bathrooms_inside']) && $input['has_bathrooms_inside'] ? true : false;
                     $old->is_exterior = isset($input['is_exterior']) && $input['is_exterior'] ? true : false;
                     $old->n_elevators = $input['n_elevators'];
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->n_parking_spaces = $input['n_parking_spaces'];
                     $old->has_steel_door = isset($input['has_steel_door']) && $input['has_steel_door'] ? true : false;
                     $old->has_security_system = isset($input['has_security_system']) && $input['has_security_system'] ? true : false;
                     $old->has_access_control = isset($input['has_access_control']) && $input['has_access_control'] ? true : false;
                     $old->has_fire_detectors = isset($input['has_fire_detectors']) && $input['has_fire_detectors'] ? true : false;
                     $old->has_fire_extinguishers = isset($input['has_fire_extinguishers']) && $input['has_fire_extinguishers'] ? true : false;
                     $old->has_fire_sprinklers = isset($input['has_fire_sprinklers']) && $input['has_fire_sprinklers'] ? true : false;
                     $old->has_fireproof_doors = isset($input['has_fireproof_doors']) && $input['has_fireproof_doors'] ? true : false;
                     $old->has_emergency_lights = isset($input['has_emergency_lights']) && $input['has_emergency_lights'] ? true : false;
                     $old->has_doorman = isset($input['has_doorman']) && $input['has_doorman'] ? true : false;
                     $old->has_air_conditioning_preinstallation = isset($input['has_air_conditioning_preinstallation']) && $input['has_air_conditioning_preinstallation'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_heating = isset($input['has_heating']) && $input['has_heating'] ? true : false;
                     $old->has_hot_water = isset($input['has_hot_water']) && $input['has_hot_water'] ? true : false;
                     $old->has_kitchen = isset($input['has_kitchen']) && $input['has_kitchen'] ? true : false;
                     $old->has_archive = isset($input['has_archive']) && $input['has_archive'] ? true : false;
                     $old->has_double_windows = isset($input['has_double_windows']) && $input['has_double_windows'] ? true : false;
                     $old->has_suspended_ceiling = isset($input['has_suspended_ceiling']) && $input['has_suspended_ceiling'] ? true : false;
                     $old->has_suspended_floor = isset($input['has_suspended_floor']) && $input['has_suspended_floor'] ? true : false;
                     $old->is_handicapped_adapted = isset($input['is_handicapped_adapted']) && $input['is_handicapped_adapted'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '4':
                     //business
                     $old = SellBusiness::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->community_cost = $input['community_cost'];
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->floor_number = $input['floor_number'];
                     $old->door = $input['door'];
                     $old->has_block = isset($input['has_block']) && $input['has_block'] ? true : false;
                     $old->block = isset($input['has_block']) && $input['has_block'] && isset($input['block']) ? $input['block'] : null;
                     $old->residential_area = $input['residential_area'];
                     $old->category_business_id = $input['category_business_id'];
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->business_distribution_id = $input['business_distribution_id'];
                     $old->business_facade_id = $input['business_facade_id'];
                     $old->n_shop_windows = $input['n_shop_windows'];
                     $old->business_location_id = $input['business_location_id'];
                     $old->n_floors = $input['n_floors'];
                     $old->n_restrooms = $input['n_restrooms'];
                     $old->last_activity = $input['last_activity'];
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->has_archive = isset($input['has_archive']) && $input['has_archive'] ? true : false;
                     $old->has_smoke_extractor = isset($input['has_smoke_extractor']) && $input['has_smoke_extractor'] ? true : false;
                     $old->has_fully_equipped_kitchen = isset($input['has_fully_equipped_kitchen']) && $input['has_fully_equipped_kitchen'] ? true : false;
                     $old->has_steel_door = isset($input['has_steel_door']) && $input['has_steel_door'] ? true : false;
                     $old->has_alarm = isset($input['has_alarm']) && $input['has_alarm'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_heating = isset($input['has_heating']) && $input['has_heating'] ? true : false;
                     $old->has_security_camera = isset($input['has_security_camera']) && $input['has_security_camera'] ? true : false;
                     $old->is_corner_located = isset($input['is_corner_located']) && $input['is_corner_located'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '5':
                     //garage
                     $old = SellGarage::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->community_cost = $input['community_cost'];
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->residential_area = $input['residential_area'];
                     $old->garage_capacity_id = $input['garage_capacity_id'];
                     $old->is_covered = isset($input['is_covered']) && $input['is_covered'] ? true : false;
                     $old->has_automatic_door = isset($input['has_automatic_door']) && $input['has_automatic_door'] ? true : false;
                     $old->has_lift = isset($input['has_lift']) && $input['has_lift'] ? true : false;
                     $old->has_alarm = isset($input['has_alarm']) && $input['has_alarm'] ? true : false;
                     $old->has_security_camera = isset($input['has_security_camera']) && $input['has_security_camera'] ? true : false;
                     $old->has_security_guard = isset($input['has_security_guard']) && $input['has_security_guard'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '6':
                     //land
                     $old = SellLand::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->residential_area = $input['residential_area'];
                     $old->category_land_id = $input['category_land_id'];
                     $old->area_total = $input['area_total'];
                     $old->area_building_land = $input['area_building_land'];
                     $old->area_min_for_sale = $input['area_min_for_sale'];
                     $old->is_classified_residential_block = isset($input['is_classified_residential_block']) && $input['is_classified_residential_block'] ? true : false;
                     $old->is_classified_residential_house = isset($input['is_classified_residential_house']) && $input['is_classified_residential_house'] ? true : false;
                     $old->is_classified_office = isset($input['is_classified_office']) && $input['is_classified_office'] ? true : false;
                     $old->is_classified_commercial = isset($input['is_classified_commercial']) && $input['is_classified_commercial'] ? true : false;
                     $old->is_classified_hotel = isset($input['is_classified_hotel']) && $input['is_classified_hotel'] ? true : false;
                     $old->is_classified_industrial = isset($input['is_classified_industrial']) && $input['is_classified_industrial'] ? true : false;
                     $old->is_classified_public_service = isset($input['is_classified_public_service']) && $input['is_classified_public_service'] ? true : false;
                     $old->is_classified_others = isset($input['is_classified_others']) && $input['is_classified_others'] ? true : false;
                     $old->max_floors_allowed = $input['max_floors_allowed'];
                     $old->has_road_access = isset($input['has_road_access']) && $input['has_road_access'] ? true : false;
                     $old->nearest_town_distance_id = $input['nearest_town_distance_id'];
                     $old->has_water = isset($input['has_water']) && $input['has_water'] ? true : false;
                     $old->has_electricity = isset($input['has_electricity']) && $input['has_electricity'] ? true : false;
                     $old->has_sewer_system = isset($input['has_sewer_system']) && $input['has_sewer_system'] ? true : false;
                     $old->has_natural_gas = isset($input['has_natural_gas']) && $input['has_natural_gas'] ? true : false;
                     $old->has_street_lighting = isset($input['has_street_lighting']) && $input['has_street_lighting'] ? true : false;
                     $old->has_sidewalks = isset($input['has_sidewalks']) && $input['has_sidewalks'] ? true : false;
                     $old->description = $input['description'];
                     break;
             }
             break;
         case '1':
             //rent
             switch ($input['typology']) {
                 case '0':
                     //apartment
                     $old = RentApartment::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->deposit = $input['deposit'];
                     $old->is_bank_agency = isset($input['is_bank_agency']) && $input['is_bank_agency'] ? true : false;
                     $old->is_state_subsidized = isset($input['is_state_subsidized']) && $input['is_state_subsidized'] ? true : false;
                     $old->is_new_development = isset($input['is_new_development']) && $input['is_new_development'] ? true : false;
                     $old->is_new_development_finished = isset($input['is_new_development_finished']) && $input['is_new_development_finished'] ? true : false;
                     $old->is_rent_to_own = isset($input['is_rent_to_own']) && $input['is_rent_to_own'] ? true : false;
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->floor_number = $input['floor_number'];
                     $old->is_last_floor = isset($input['is_last_floor']) && $input['is_last_floor'] ? true : false;
                     $old->door = $input['door'];
                     $old->has_block = isset($input['has_block']) && $input['has_block'] ? true : false;
                     $old->block = isset($input['has_block']) && $input['has_block'] && isset($input['block']) ? $input['block'] : null;
                     $old->residential_area = $input['residential_area'];
                     $old->is_regular = isset($input['is_regular']) && $input['is_regular'] ? true : false;
                     $old->is_penthouse = isset($input['is_penthouse']) && $input['is_penthouse'] ? true : false;
                     $old->is_duplex = isset($input['is_duplex']) && $input['is_duplex'] ? true : false;
                     $old->is_studio = isset($input['is_studio']) && $input['is_studio'] ? true : false;
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->n_bedrooms = $input['n_bedrooms'];
                     $old->n_bathrooms = $input['n_bathrooms'];
                     $old->is_exterior = isset($input['is_exterior']) && $input['is_exterior'] ? true : false;
                     $old->has_equipped_kitchen = isset($input['has_equipped_kitchen']) && $input['has_equipped_kitchen'] ? true : false;
                     $old->has_furniture = isset($input['has_furniture']) && $input['has_furniture'] ? true : false;
                     $old->has_elevator = isset($input['has_elevator']) && $input['has_elevator'] ? true : false;
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->faces_north = isset($input['faces_north']) && $input['faces_north'] ? true : false;
                     $old->faces_south = isset($input['faces_south']) && $input['faces_south'] ? true : false;
                     $old->faces_east = isset($input['faces_east']) && $input['faces_east'] ? true : false;
                     $old->faces_west = isset($input['faces_west']) && $input['faces_west'] ? true : false;
                     $old->has_builtin_closets = isset($input['has_builtin_closets']) && $input['has_builtin_closets'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_terrace = isset($input['has_terrace']) && $input['has_terrace'] ? true : false;
                     $old->has_box_room = isset($input['has_box_room']) && $input['has_box_room'] ? true : false;
                     $old->has_parking_space = isset($input['has_parking_space']) && $input['has_parking_space'] ? true : false;
                     $old->has_swimming_pool = isset($input['has_swimming_pool']) && $input['has_swimming_pool'] ? true : false;
                     $old->has_garden = isset($input['has_garden']) && $input['has_garden'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '1':
                     //house
                     $old = RentHouse::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->deposit = $input['deposit'];
                     $old->is_bank_agency = isset($input['is_bank_agency']) && $input['is_bank_agency'] ? true : false;
                     $old->is_state_subsidized = isset($input['is_state_subsidized']) && $input['is_state_subsidized'] ? true : false;
                     $old->is_new_development = isset($input['is_new_development']) && $input['is_new_development'] ? true : false;
                     $old->is_new_development_finished = isset($input['is_new_development_finished']) && $input['is_new_development_finished'] ? true : false;
                     $old->is_rent_to_own = isset($input['is_rent_to_own']) && $input['is_rent_to_own'] ? true : false;
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->residential_area = $input['residential_area'];
                     $old->category_house_id = $input['category_house_id'];
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->area_land = $input['area_land'];
                     $old->n_floors = $input['n_floors'];
                     $old->n_bedrooms = $input['n_bedrooms'];
                     $old->n_bathrooms = $input['n_bathrooms'];
                     $old->has_equipped_kitchen = isset($input['has_equipped_kitchen']) && $input['has_equipped_kitchen'] ? true : false;
                     $old->has_furniture = isset($input['has_furniture']) && $input['has_furniture'] ? true : false;
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->faces_north = isset($input['faces_north']) && $input['faces_north'] ? true : false;
                     $old->faces_south = isset($input['faces_south']) && $input['faces_south'] ? true : false;
                     $old->faces_east = isset($input['faces_east']) && $input['faces_east'] ? true : false;
                     $old->faces_west = isset($input['faces_west']) && $input['faces_west'] ? true : false;
                     $old->has_builtin_closets = isset($input['has_builtin_closets']) && $input['has_builtin_closets'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_terrace = isset($input['has_terrace']) && $input['has_terrace'] ? true : false;
                     $old->has_box_room = isset($input['has_box_room']) && $input['has_box_room'] ? true : false;
                     $old->has_parking_space = isset($input['has_parking_space']) && $input['has_parking_space'] ? true : false;
                     $old->has_fireplace = isset($input['has_fireplace']) && $input['has_fireplace'] ? true : false;
                     $old->has_swimming_pool = isset($input['has_swimming_pool']) && $input['has_swimming_pool'] ? true : false;
                     $old->has_garden = isset($input['has_garden']) && $input['has_garden'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '2':
                     //country house
                     $old = RentCountryHouse::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->deposit = $input['deposit'];
                     $old->is_bank_agency = isset($input['is_bank_agency']) && $input['is_bank_agency'] ? true : false;
                     $old->is_state_subsidized = isset($input['is_state_subsidized']) && $input['is_state_subsidized'] ? true : false;
                     $old->is_new_development = isset($input['is_new_development']) && $input['is_new_development'] ? true : false;
                     $old->is_new_development_finished = isset($input['is_new_development_finished']) && $input['is_new_development_finished'] ? true : false;
                     $old->is_rent_to_own = isset($input['is_rent_to_own']) && $input['is_rent_to_own'] ? true : false;
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->residential_area = $input['residential_area'];
                     $old->category_country_house_id = $input['category_country_house_id'];
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->area_land = $input['area_land'];
                     $old->n_floors = $input['n_floors'];
                     $old->n_bedrooms = $input['n_bedrooms'];
                     $old->n_bathrooms = $input['n_bathrooms'];
                     $old->has_equipped_kitchen = isset($input['has_equipped_kitchen']) && $input['has_equipped_kitchen'] ? true : false;
                     $old->has_furniture = isset($input['has_furniture']) && $input['has_furniture'] ? true : false;
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->faces_north = isset($input['faces_north']) && $input['faces_north'] ? true : false;
                     $old->faces_south = isset($input['faces_south']) && $input['faces_south'] ? true : false;
                     $old->faces_east = isset($input['faces_east']) && $input['faces_east'] ? true : false;
                     $old->faces_west = isset($input['faces_west']) && $input['faces_west'] ? true : false;
                     $old->has_builtin_closets = isset($input['has_builtin_closets']) && $input['has_builtin_closets'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_terrace = isset($input['has_terrace']) && $input['has_terrace'] ? true : false;
                     $old->has_box_room = isset($input['has_box_room']) && $input['has_box_room'] ? true : false;
                     $old->has_parking_space = isset($input['has_parking_space']) && $input['has_parking_space'] ? true : false;
                     $old->has_fireplace = isset($input['has_fireplace']) && $input['has_fireplace'] ? true : false;
                     $old->has_swimming_pool = isset($input['has_swimming_pool']) && $input['has_swimming_pool'] ? true : false;
                     $old->has_garden = isset($input['has_garden']) && $input['has_garden'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '3':
                     //office
                     $old = RentOffice::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->deposit = $input['deposit'];
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->floor_number = $input['floor_number'];
                     $old->door = $input['door'];
                     $old->has_block = isset($input['has_block']) && $input['has_block'] ? true : false;
                     $old->block = isset($input['has_block']) && $input['has_block'] && isset($input['block']) ? $input['block'] : null;
                     $old->residential_area = $input['residential_area'];
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->area_min_for_sale = $input['area_min_for_sale'];
                     $old->n_floors = $input['n_floors'];
                     $old->has_offices_only = isset($input['']) && $input[''] ? true : false;
                     $old->office_distribution_id = $input['office_distribution_id'];
                     $old->n_restrooms = $input['n_restrooms'];
                     $old->has_bathrooms = isset($input['has_bathrooms']) && $input['has_bathrooms'] ? true : false;
                     $old->has_bathrooms_inside = isset($input['has_bathrooms_inside']) && $input['has_bathrooms_inside'] ? true : false;
                     $old->is_exterior = isset($input['is_exterior']) && $input['is_exterior'] ? true : false;
                     $old->n_elevators = $input['n_elevators'];
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->n_parking_spaces = $input['n_parking_spaces'];
                     $old->has_steel_door = isset($input['has_steel_door']) && $input['has_steel_door'] ? true : false;
                     $old->has_security_system = isset($input['has_security_system']) && $input['has_security_system'] ? true : false;
                     $old->has_access_control = isset($input['has_access_control']) && $input['has_access_control'] ? true : false;
                     $old->has_fire_detectors = isset($input['has_fire_detectors']) && $input['has_fire_detectors'] ? true : false;
                     $old->has_fire_extinguishers = isset($input['has_fire_extinguishers']) && $input['has_fire_extinguishers'] ? true : false;
                     $old->has_fire_sprinklers = isset($input['has_fire_sprinklers']) && $input['has_fire_sprinklers'] ? true : false;
                     $old->has_fireproof_doors = isset($input['has_fireproof_doors']) && $input['has_fireproof_doors'] ? true : false;
                     $old->has_emergency_lights = isset($input['has_emergency_lights']) && $input['has_emergency_lights'] ? true : false;
                     $old->has_doorman = isset($input['has_doorman']) && $input['has_doorman'] ? true : false;
                     $old->has_air_conditioning_preinstallation = isset($input['has_air_conditioning_preinstallation']) && $input['has_air_conditioning_preinstallation'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_heating = isset($input['has_heating']) && $input['has_heating'] ? true : false;
                     $old->has_hot_water = isset($input['has_hot_water']) && $input['has_hot_water'] ? true : false;
                     $old->has_kitchen = isset($input['has_kitchen']) && $input['has_kitchen'] ? true : false;
                     $old->has_archive = isset($input['has_archive']) && $input['has_archive'] ? true : false;
                     $old->has_double_windows = isset($input['has_double_windows']) && $input['has_double_windows'] ? true : false;
                     $old->has_suspended_ceiling = isset($input['has_suspended_ceiling']) && $input['has_suspended_ceiling'] ? true : false;
                     $old->has_suspended_floor = isset($input['has_suspended_floor']) && $input['has_suspended_floor'] ? true : false;
                     $old->is_handicapped_adapted = isset($input['is_handicapped_adapted']) && $input['is_handicapped_adapted'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '4':
                     //business
                     $old = RentBusiness::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->is_transfer = isset($input['is_transfer']) && $input['is_transfer'] ? true : false;
                     $old->deposit = $input['deposit'];
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->floor_number = $input['floor_number'];
                     $old->door = $input['door'];
                     $old->has_block = isset($input['has_block']) && $input['has_block'] ? true : false;
                     $old->block = isset($input['has_block']) && $input['has_block'] && isset($input['block']) ? $input['block'] : null;
                     $old->residential_area = $input['residential_area'];
                     $old->category_business_id = $input['category_business_id'];
                     $old->needs_restoration = isset($input['needs_restoration']) && $input['needs_restoration'] ? true : false;
                     $old->area_constructed = $input['area_constructed'];
                     $old->area_usable = $input['area_usable'];
                     $old->business_distribution_id = $input['business_distribution_id'];
                     $old->business_facade_id = $input['business_facade_id'];
                     $old->n_shop_windows = $input['n_shop_windows'];
                     $old->business_location_id = $input['business_location_id'];
                     $old->n_floors = $input['n_floors'];
                     $old->n_restrooms = $input['n_restrooms'];
                     $old->last_activity = $input['last_activity'];
                     $old->energy_certification_id = $input['energy_certification_id'];
                     $old->energy_performance = $input['energy_performance'];
                     $old->has_archive = isset($input['has_archive']) && $input['has_archive'] ? true : false;
                     $old->has_smoke_extractor = isset($input['has_smoke_extractor']) && $input['has_smoke_extractor'] ? true : false;
                     $old->has_fully_equipped_kitchen = isset($input['has_fully_equipped_kitchen']) && $input['has_fully_equipped_kitchen'] ? true : false;
                     $old->has_steel_door = isset($input['has_steel_door']) && $input['has_steel_door'] ? true : false;
                     $old->has_alarm = isset($input['has_alarm']) && $input['has_alarm'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_heating = isset($input['has_heating']) && $input['has_heating'] ? true : false;
                     $old->has_security_camera = isset($input['has_security_camera']) && $input['has_security_camera'] ? true : false;
                     $old->is_corner_located = isset($input['is_corner_located']) && $input['is_corner_located'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '5':
                     //garage
                     $old = RentGarage::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->deposit = $input['deposit'];
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->residential_area = $input['residential_area'];
                     $old->garage_capacity_id = $input['garage_capacity_id'];
                     $old->is_covered = isset($input['is_covered']) && $input['is_covered'] ? true : false;
                     $old->has_automatic_door = isset($input['has_automatic_door']) && $input['has_automatic_door'] ? true : false;
                     $old->has_lift = isset($input['has_lift']) && $input['has_lift'] ? true : false;
                     $old->has_alarm = isset($input['has_alarm']) && $input['has_alarm'] ? true : false;
                     $old->has_security_camera = isset($input['has_security_camera']) && $input['has_security_camera'] ? true : false;
                     $old->has_security_guard = isset($input['has_security_guard']) && $input['has_security_guard'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '6':
                     //land
                     $old = RentLand::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->deposit = $input['deposit'];
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->residential_area = $input['residential_area'];
                     $old->category_land_id = $input['category_land_id'];
                     $old->area_total = $input['area_total'];
                     $old->area_building_land = $input['area_building_land'];
                     $old->area_min_for_sale = $input['area_min_for_sale'];
                     $old->is_classified_residential_block = isset($input['is_classified_residential_block']) && $input['is_classified_residential_block'] ? true : false;
                     $old->is_classified_residential_house = isset($input['is_classified_residential_house']) && $input['is_classified_residential_house'] ? true : false;
                     $old->is_classified_office = isset($input['is_classified_office']) && $input['is_classified_office'] ? true : false;
                     $old->is_classified_commercial = isset($input['is_classified_commercial']) && $input['is_classified_commercial'] ? true : false;
                     $old->is_classified_hotel = isset($input['is_classified_hotel']) && $input['is_classified_hotel'] ? true : false;
                     $old->is_classified_industrial = isset($input['is_classified_industrial']) && $input['is_classified_industrial'] ? true : false;
                     $old->is_classified_public_service = isset($input['is_classified_public_service']) && $input['is_classified_public_service'] ? true : false;
                     $old->is_classified_others = isset($input['is_classified_others']) && $input['is_classified_others'] ? true : false;
                     $old->max_floors_allowed = $input['max_floors_allowed'];
                     $old->has_road_access = isset($input['has_road_access']) && $input['has_road_access'] ? true : false;
                     $old->nearest_town_distance_id = $input['nearest_town_distance_id'];
                     $old->has_water = isset($input['has_water']) && $input['has_water'] ? true : false;
                     $old->has_electricity = isset($input['has_electricity']) && $input['has_electricity'] ? true : false;
                     $old->has_sewer_system = isset($input['has_sewer_system']) && $input['has_sewer_system'] ? true : false;
                     $old->has_natural_gas = isset($input['has_natural_gas']) && $input['has_natural_gas'] ? true : false;
                     $old->has_street_lighting = isset($input['has_street_lighting']) && $input['has_street_lighting'] ? true : false;
                     $old->has_sidewalks = isset($input['has_sidewalks']) && $input['has_sidewalks'] ? true : false;
                     $old->description = $input['description'];
                     break;
                 case '7':
                     //vacation (lodging)
                     $old = Lodging::findOrFail($input['local_id']);
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->floor_number = $input['floor_number'];
                     $old->is_last_floor = isset($input['is_last_floor']) && $input['is_last_floor'] ? true : false;
                     $old->door = $input['door'];
                     $old->has_block = isset($input['has_block']) && $input['has_block'] ? true : false;
                     $old->block = isset($input['has_block']) && $input['has_block'] && isset($input['block']) ? $input['block'] : null;
                     $old->residential_area = $input['residential_area'];
                     $old->surroundings_id = $input['surroundings_id'];
                     $old->category_lodging_id = $input['category_lodging_id'];
                     $old->has_multiple_lodgings = isset($input['has_multiple_lodgings']) && $input['has_multiple_lodgings'] ? true : false;
                     $old->area_total = $input['area_total'];
                     $old->area_garden = $input['area_garden'];
                     $old->area_terrace = $input['area_terrace'];
                     $old->is_american_kitchen = isset($input['is_american_kitchen']) && $input['is_american_kitchen'] ? true : false;
                     $old->distance_to_beach = $input['distance_to_beach'];
                     $old->distance_to_town_center = $input['distance_to_town_center'];
                     $old->distance_to_ski_area = $input['distance_to_ski_area'];
                     $old->distance_to_golf_course = $input['distance_to_golf_course'];
                     $old->distance_to_airport = $input['distance_to_airport'];
                     $old->distance_to_supermarket = $input['distance_to_supermarket'];
                     $old->distance_to_river_or_lake = $input['distance_to_river_or_lake'];
                     $old->distance_to_marina = $input['distance_to_marina'];
                     $old->distance_to_horse_riding_area = $input['distance_to_horse_riding_area'];
                     $old->distance_to_scuba_diving_area = $input['distance_to_scuba_diving_area'];
                     $old->distance_to_train_station = $input['distance_to_train_station'];
                     $old->distance_to_bus_station = $input['distance_to_bus_station'];
                     $old->distance_to_hospital = $input['distance_to_hospital'];
                     $old->distance_to_hiking_area = $input['distance_to_hiking_area'];
                     $old->n_double_bedroom = $input['n_double_bedroom'];
                     $old->n_two_beds_room = $input['n_two_beds_room'];
                     $old->n_single_bed_room = $input['n_single_bed_room'];
                     $old->n_three_beds_room = $input['n_three_beds_room'];
                     $old->n_four_beds_room = $input['n_four_beds_room'];
                     $old->n_sofa_bed = $input['n_sofa_bed'];
                     $old->n_double_sofa_bed = $input['n_double_sofa_bed'];
                     $old->n_extra_bed = $input['n_extra_bed'];
                     $old->min_capacity = $input['min_capacity'];
                     $old->max_capacity = $input['max_capacity'];
                     $old->has_booking = $input['has_booking'];
                     $old->booking = isset($input['has_booking']) && $input['has_booking'] ? $input['booking'] : null;
                     $old->has_deposit = $input['has_deposit'];
                     $old->deposit = isset($input['has_deposit']) && $input['has_deposit'] ? $input['deposit'] : null;
                     $old->payment_day_id = $input['payment_day_id'];
                     $old->n_days_before = isset($input['n_days_before']) ? $input['n_days_before'] : null;
                     $old->has_cleaning = isset($input['has_cleaning']) && $input['has_cleaning'] ? true : false;
                     $old->cleaning = isset($input['has_cleaning']) && !$input['has_cleaning'] && isset($input['cleaning']) ? $input['cleaning'] : null;
                     $old->has_included_towels = isset($input['has_included_towels']) && $input['has_included_towels'] ? true : false;
                     $old->has_included_expenses = isset($input['has_included_expenses']) && $input['has_included_expenses'] ? true : false;
                     $old->accepts_cash = isset($input['accepts_cash']) && $input['accepts_cash'] ? true : false;
                     $old->accepts_transfer = isset($input['accepts_transfer']) && $input['accepts_transfer'] ? true : false;
                     $old->accepts_credit_card = isset($input['accepts_credit_card']) && $input['accepts_credit_card'] ? true : false;
                     $old->accepts_paypal = isset($input['accepts_paypal']) && $input['accepts_paypal'] ? true : false;
                     $old->accepts_check = isset($input['accepts_check']) && $input['accepts_check'] ? true : false;
                     $old->accepts_western_union = isset($input['accepts_western_union']) && $input['accepts_western_union'] ? true : false;
                     $old->accepts_money_gram = isset($input['accepts_money_gram']) && $input['accepts_money_gram'] ? true : false;
                     $old->has_barbecue = isset($input['has_barbecue']) && $input['has_barbecue'] ? true : false;
                     $old->has_terrace = isset($input['has_terrace']) && $input['has_terrace'] ? true : false;
                     $old->has_private_swimming_pool = isset($input['has_private_swimming_pool']) && $input['has_private_swimming_pool'] ? true : false;
                     $old->has_shared_swimming_pool = isset($input['has_shared_swimming_pool']) && $input['has_shared_swimming_pool'] ? true : false;
                     $old->has_indoor_swimming_pool = isset($input['has_indoor_swimming_pool']) && $input['has_indoor_swimming_pool'] ? true : false;
                     $old->has_private_garden = isset($input['has_private_garden']) && $input['has_private_garden'] ? true : false;
                     $old->has_shared_garden = isset($input['has_shared_garden']) && $input['has_shared_garden'] ? true : false;
                     $old->has_furnished_garden = isset($input['has_furnished_garden']) && $input['has_furnished_garden'] ? true : false;
                     $old->has_parking_space = isset($input['has_parking_space']) && $input['has_parking_space'] ? true : false;
                     $old->has_playground = isset($input['has_playground']) && $input['has_playground'] ? true : false;
                     $old->has_mountain_sights = isset($input['has_mountain_sights']) && $input['has_mountain_sights'] ? true : false;
                     $old->has_sea_sights = isset($input['has_sea_sights']) && $input['has_sea_sights'] ? true : false;
                     $old->has_fireplace = isset($input['has_fireplace']) && $input['has_fireplace'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_jacuzzi = isset($input['has_jacuzzi']) && $input['has_jacuzzi'] ? true : false;
                     $old->has_tv = isset($input['has_tv']) && $input['has_tv'] ? true : false;
                     $old->has_cable_tv = isset($input['has_cable_tv']) && $input['has_cable_tv'] ? true : false;
                     $old->has_internet = isset($input['has_internet']) && $input['has_internet'] ? true : false;
                     $old->has_heating = isset($input['has_heating']) && $input['has_heating'] ? true : false;
                     $old->has_fan = isset($input['has_fan']) && $input['has_fan'] ? true : false;
                     $old->has_cradle = isset($input['has_cradle']) && $input['has_cradle'] ? true : false;
                     $old->has_hairdryer = isset($input['has_hairdryer']) && $input['has_hairdryer'] ? true : false;
                     $old->has_dishwasher = isset($input['has_dishwasher']) && $input['has_dishwasher'] ? true : false;
                     $old->has_fridge = isset($input['has_fridge']) && $input['has_fridge'] ? true : false;
                     $old->has_oven = isset($input['has_oven']) && $input['has_oven'] ? true : false;
                     $old->has_microwave = isset($input['has_microwave']) && $input['has_microwave'] ? true : false;
                     $old->has_coffee_maker = isset($input['has_coffee_maker']) && $input['has_coffee_maker'] ? true : false;
                     $old->has_dryer = isset($input['has_dryer']) && $input['has_dryer'] ? true : false;
                     $old->has_washer = isset($input['has_washer']) && $input['has_washer'] ? true : false;
                     $old->has_iron = isset($input['has_iron']) && $input['has_iron'] ? true : false;
                     $old->is_smoking_allowed = isset($input['is_smoking_allowed']) && $input['is_smoking_allowed'] ? true : false;
                     $old->is_pet_allowed = isset($input['is_pet_allowed']) && $input['is_pet_allowed'] ? true : false;
                     $old->has_elevator = isset($input['has_elevator']) && $input['has_elevator'] ? true : false;
                     $old->is_car_recommended = isset($input['is_car_recommended']) && $input['is_car_recommended'] ? true : false;
                     $old->is_handicapped_adapted = isset($input['is_handicapped_adapter']) && $input['is_handicapped_adapter'] ? true : false;
                     $old->is_out_town_center = isset($input['is_out_town_center']) && $input['is_out_town_center'] ? true : false;
                     $old->is_isolated = isset($input['is_isolated']) && $input['is_isolated'] ? true : false;
                     $old->is_nudist_area = isset($input['is_nudist_area']) && $input['is_nudist_area'] ? true : false;
                     $old->is_bar_area = isset($input['is_bar_area']) && $input['is_bar_area'] ? true : false;
                     $old->is_gayfriendly_area = isset($input['is_gayfriendly_area']) && $input['is_gayfriendly_area'] ? true : false;
                     $old->is_family_tourism_area = isset($input['is_family_tourism_area']) && $input['is_family_tourism_area'] ? true : false;
                     $old->is_luxury_area = isset($input['is_luxury_area']) && $input['is_luxury_area'] ? true : false;
                     $old->is_charming = isset($input['is_charming']) && $input['is_charming'] ? true : false;
                     $old->has_bicycle_rental = isset($input['has_bicycle_rental']) && $input['has_bicycle_rental'] ? true : false;
                     $old->has_car_rental = isset($input['has_car_rental']) && $input['has_car_rental'] ? true : false;
                     $old->has_adventure_activities = isset($input['has_adventure_activities']) && $input['has_adventure_activities'] ? true : false;
                     $old->has_kindergarten = isset($input['has_kindergarten']) && $input['has_kindergarten'] ? true : false;
                     $old->has_sauna = isset($input['has_sauna']) && $input['has_sauna'] ? true : false;
                     $old->has_tennis_court = isset($input['has_tennis_court']) && $input['has_tennis_court'] ? true : false;
                     $old->has_paddle_court = isset($input['has_paddle_court']) && $input['has_paddle_court'] ? true : false;
                     $old->has_gym = isset($input['has_gym']) && $input['has_gym'] ? true : false;
                     $old->description = $input['description'];
                     //delete old prices
                     $old->prices()->delete();
                     //associate new prices with old lodging
                     foreach ($input as $key => $value) {
                         $exp_key = explode('-', $key);
                         if ($exp_key[0] == 'n_season') {
                             SeasonPrice::create(['n_season' => $value, 'from_date' => Carbon::createFromFormat('d/m/Y', $input['from_date-' . $value]), 'to_date' => Carbon::createFromFormat('d/m/Y', $input['to_date-' . $value]), 'p_one_night' => $input['p_one_night-' . $value], 'p_weekend_night' => $input['p_weekend_night-' . $value], 'p_one_week' => $input['p_one_week-' . $value], 'p_half_month' => $input['p_half_month-' . $value], 'p_one_month' => $input['p_one_month-' . $value], 'p_extra_guest_per_night' => $input['p_extra_guest_per_night-' . $value], 'n_min_nights' => $input['n_min_nights-' . $value], 'rent_vacation_id' => $old->id]);
                         }
                     }
                     break;
                 case '8':
                     //room
                     $old = Room::findOrFail($input['local_id']);
                     $old->price = $input['price'];
                     $old->deposit = $input['deposit'];
                     $old->lat = $input['lat'];
                     $old->lng = $input['lng'];
                     $old->formatted_address = $input['formatted_address'];
                     $old->street_number = $input['street_number'];
                     $old->route = $input['route'];
                     $old->locality = $input['locality'];
                     $old->admin_area_lvl2 = $input['admin_area_lvl2'];
                     $old->admin_area_lvl1 = $input['admin_area_lvl1'];
                     $old->country = $input['country'];
                     $old->postal_code = $input['postal_code'];
                     $old->hide_address = isset($input['hide_address']) && $input['hide_address'] ? true : false;
                     $old->floor_number = $input['floor_number'];
                     $old->is_last_floor = isset($input['is_last_floor']) && $input['is_last_floor'] ? true : false;
                     $old->door = $input['door'];
                     $old->has_block = isset($input['has_block']) && $input['has_block'] ? true : false;
                     $old->block = isset($input['has_block']) && $input['has_block'] && isset($input['block']) ? $input['block'] : null;
                     $old->residential_area = $input['residential_area'];
                     $old->category_room_id = $input['category_room_id'];
                     $old->area_room = $input['area_room'];
                     $old->n_people = $input['n_people'];
                     $old->n_bedrooms = $input['n_bedrooms'];
                     $old->n_bathrooms = $input['n_bathrooms'];
                     $old->current_tenants_gender_id = $input['current_tenants_gender_id'];
                     $old->is_smoking_allowed = isset($input['is_smoking_allowed']) && $input['is_smoking_allowed'] ? true : false;
                     $old->is_pet_allowed = isset($input['is_pet_allowed']) && $input['is_pet_allowed'] ? true : false;
                     $old->min_current_tenants_age = $input['min_current_tenants_age'];
                     $old->max_current_tenants_age = $input['max_current_tenants_age'];
                     $old->has_elevator = isset($input['has_elevator']) && $input['has_elevator'] ? true : false;
                     $old->has_furniture = isset($input['has_furniture']) && $input['has_furniture'] ? true : false;
                     $old->has_builtin_closets = isset($input['has_builtin_closets']) && $input['has_builtin_closets'] ? true : false;
                     $old->has_air_conditioning = isset($input['has_air_conditioning']) && $input['has_air_conditioning'] ? true : false;
                     $old->has_internet = isset($input['has_internet']) && $input['has_internet'] ? true : false;
                     $old->has_house_keeper = isset($input['has_house_keeper']) && $input['has_house_keeper'] ? true : false;
                     $old->tenant_gender_id = $input['tenant_gender_id'];
                     $old->tenant_occupation_id = $input['tenant_occupation_id'];
                     $old->tenant_sexual_orientation_id = $input['tenant_sexual_orientation_id'];
                     $old->tenant_min_stay_id = $input['tenant_min_stay_id'];
                     $old->description = $input['description'];
                     break;
             }
             break;
     }
     //return success to admin dashboard
     if (isset($old) && $old->save()) {
         $Ad->touch();
         return redirect('dashboard')->with('success', ['Stitle' => 'Editar anuncio', 'Smsg' => 'Los datos del anuncio han sido actualizados satisfactoriamente.']);
     }
     return redirect('dashboard')->with('error', ['Etitle' => 'Editar anuncio', 'Emsg' => 'Se produjo un error al tratar de actualizar los datos del anuncio. Si el problema persiste póngase en contacto con el servicio técnico de la aplicación.']);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     define('THIS_MANY_ADS', \App\Constants::first()->n_ad_seeds);
     $faker = Faker\Factory::create('es_ES');
     $n_house_categories = DB::table('category_house')->count();
     $n_country_house_categories = DB::table('category_country_house')->count();
     $n_business_categories = DB::table('category_business')->count();
     $n_land_categories = DB::table('category_land')->count();
     $n_lodging_categories = DB::table('category_lodging')->count();
     $n_room_categories = DB::table('category_room')->count();
     $n_energy_certification_options = DB::table('energy_certification')->count();
     $n_business_distribution_options = DB::table('business_distribution')->count();
     $n_business_facade_options = DB::table('business_facade')->count();
     $n_business_location_options = DB::table('business_location')->count();
     $n_current_tenants_gender_options = DB::table('current_tenants_gender')->count();
     $n_garage_capacity_options = DB::table('garage_capacity')->count();
     $n_nearest_town_distance_options = DB::table('nearest_town_distance')->count();
     $n_office_distribution_options = DB::table('office_distribution')->count();
     $n_payment_day_options = DB::table('payment_day')->count();
     $n_surroundings_options = DB::table('surroundings')->count();
     $n_tenant_gender_options = DB::table('tenant_gender')->count();
     $n_tenant_min_stay_options = DB::table('tenant_min_stay')->count();
     $n_tenant_occupation_options = DB::table('tenant_occupation')->count();
     $n_tenant_sexual_orientation_options = DB::table('tenant_sexual_orientation')->count();
     $performances = ['75', '100', '125', '150', '175', '200', '225', '250'];
     $certs = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
     $blocks = ['A', 'B', 'C', 'D', 'E'];
     $doors = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', 'Puerta única', 'Izquierda', 'Derecha', 'Exterior', 'Interior', 'Centro', 'Exterior izquierda', 'Exterior derecha', 'Interior izquierda', 'Interior derecha', 'Centro izquierda', 'Centro derecha'];
     $floors = ['Planta 1º', 'Planta 2º', 'Planta 3º', 'Planta 4º', 'Planta 5º', 'Planta 6º', 'Planta 7º', 'Planta 8º', 'Planta 9º', 'Planta 10º', 'Planta 11º', 'Planta 12º', 'Planta 13º', 'Planta 14º', 'Planta 15º', 'Planta 16º', 'Planta 17º', 'Planta 18º', 'Planta 19º', 'Planta 20º', 'Planta 21º', 'Planta 22º', 'Planta 23º', 'Planta 24º', 'Planta 25º', 'Planta 26º', 'Sótano', 'Semi-sótano', 'Bajo', 'Entreplanta', 'Por debajo de la planta baja (-2)', 'Por debajo de la planta baja (-1)'];
     $activities = ['Tienda de ropa', 'Frutería', 'Panadería', 'Taller mecánico', 'Bar', 'Restaurante', 'Carnicería', 'Gestión de residuos industriales', 'Copistería', 'Fábrica de papel', 'Acerería', 'Alfarería', 'Fábrica de cemento', 'Fábrica de mezcla bituminosa', 'Tienda de respuestos'];
     $deposits = ['1 mes', '2 meses', '3 meses', '4 meses', '5 meses', '6 meses o más'];
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(600, 2000);
         $deposit = mt_rand(0, 6) ? $deposits[array_rand($deposits)] : null;
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $is_new_development = mt_rand(0, 1);
         $is_new_development_finished = $is_new_development ? mt_rand(0, 1) : 0;
         $newAd = App\Ad::create();
         $newRentHouse = \App\RentHouse::create(['ad_id' => $newAd->id, 'price' => $price, 'deposit' => $deposit, 'is_bank_agency' => mt_rand(0, 1), 'is_state_subsidized' => mt_rand(0, 1), 'is_new_development' => $is_new_development, 'is_new_development_finished' => $is_new_development_finished, 'is_rent_to_own' => mt_rand(0, 1), 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'category_house_id' => mt_rand(1, $n_house_categories), 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'area_land' => $area_land, 'n_floors' => mt_rand(1, 4), 'n_bedrooms' => mt_rand(1, 4), 'n_bathrooms' => mt_rand(1, 4), 'has_equipped_kitchen' => mt_rand(0, 1), 'has_furniture' => mt_rand(0, 1), 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'faces_north' => mt_rand(0, 1), 'faces_south' => mt_rand(0, 1), 'faces_east' => mt_rand(0, 1), 'faces_west' => mt_rand(0, 1), 'has_builtin_closets' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_terrace' => mt_rand(0, 1), 'has_box_room' => mt_rand(0, 1), 'has_parking_space' => mt_rand(0, 1), 'has_fireplace' => mt_rand(0, 1), 'has_swimming_pool' => mt_rand(0, 1), 'has_garden' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'rent_house';
         $newAd->local_id = $newRentHouse->id;
         $newAd->save();
         $this->command->info('Seeded Rent House (id: ' . $newRentHouse->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(100000, 1000000);
         $community_cost = mt_rand(0, 5) ? null : mt_rand(10, 100);
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $is_new_development = mt_rand(0, 1);
         $is_new_development_finished = $is_new_development ? mt_rand(0, 1) : 0;
         $newAd = App\Ad::create();
         $newSellHouse = \App\SellHouse::create(['ad_id' => $newAd->id, 'price' => $price, 'community_cost' => $community_cost, 'is_bank_agency' => mt_rand(0, 1), 'is_state_subsidized' => mt_rand(0, 1), 'is_new_development' => $is_new_development, 'is_new_development_finished' => $is_new_development_finished, 'is_rent_to_own' => mt_rand(0, 1), 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'category_house_id' => mt_rand(1, $n_house_categories), 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'area_land' => $area_land, 'n_floors' => mt_rand(1, 4), 'n_bedrooms' => mt_rand(1, 4), 'n_bathrooms' => mt_rand(1, 4), 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'faces_north' => mt_rand(0, 1), 'faces_south' => mt_rand(0, 1), 'faces_east' => mt_rand(0, 1), 'faces_west' => mt_rand(0, 1), 'has_builtin_closets' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_terrace' => mt_rand(0, 1), 'has_box_room' => mt_rand(0, 1), 'has_parking_space' => mt_rand(0, 1), 'has_fireplace' => mt_rand(0, 1), 'has_swimming_pool' => mt_rand(0, 1), 'has_garden' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'sell_house';
         $newAd->local_id = $newSellHouse->id;
         $newAd->save();
         $this->command->info('Seeded Sell House (id: ' . $newSellHouse->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(100000, 1000000);
         $community_cost = mt_rand(0, 5) ? null : mt_rand(10, 100);
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(300, 2400);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $is_new_development = mt_rand(0, 1);
         $is_new_development_finished = $is_new_development ? mt_rand(0, 1) : 0;
         $newAd = App\Ad::create();
         $newSellCountryHouse = \App\SellCountryHouse::create(['ad_id' => $newAd->id, 'price' => $price, 'community_cost' => $community_cost, 'is_bank_agency' => mt_rand(0, 1), 'is_state_subsidized' => mt_rand(0, 1), 'is_new_development' => $is_new_development, 'is_new_development_finished' => $is_new_development_finished, 'is_rent_to_own' => mt_rand(0, 1), 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'category_country_house_id' => mt_rand(1, $n_country_house_categories), 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'area_land' => $area_land, 'n_floors' => mt_rand(1, 4), 'n_bedrooms' => mt_rand(1, 4), 'n_bathrooms' => mt_rand(1, 4), 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'faces_north' => mt_rand(0, 1), 'faces_south' => mt_rand(0, 1), 'faces_east' => mt_rand(0, 1), 'faces_west' => mt_rand(0, 1), 'has_builtin_closets' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_terrace' => mt_rand(0, 1), 'has_box_room' => mt_rand(0, 1), 'has_parking_space' => mt_rand(0, 1), 'has_fireplace' => mt_rand(0, 1), 'has_swimming_pool' => mt_rand(0, 1), 'has_garden' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'sell_country_house';
         $newAd->local_id = $newSellCountryHouse->id;
         $newAd->save();
         $this->command->info('Seeded Sell Country House (id: ' . $newSellCountryHouse->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(600, 2000);
         $deposit = mt_rand(0, 6) ? $deposits[array_rand($deposits)] : null;
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(300, 2400);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $is_new_development = mt_rand(0, 1);
         $is_new_development_finished = $is_new_development ? mt_rand(0, 1) : 0;
         $newAd = App\Ad::create();
         $newRentCountryHouse = \App\RentCountryHouse::create(['ad_id' => $newAd->id, 'price' => $price, 'deposit' => $deposit, 'is_bank_agency' => mt_rand(0, 1), 'is_state_subsidized' => mt_rand(0, 1), 'is_new_development' => $is_new_development, 'is_new_development_finished' => $is_new_development_finished, 'is_rent_to_own' => mt_rand(0, 1), 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'category_country_house_id' => mt_rand(1, $n_country_house_categories), 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'area_land' => $area_land, 'n_floors' => mt_rand(1, 4), 'n_bedrooms' => mt_rand(1, 4), 'n_bathrooms' => mt_rand(1, 4), 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'faces_north' => mt_rand(0, 1), 'faces_south' => mt_rand(0, 1), 'faces_east' => mt_rand(0, 1), 'faces_west' => mt_rand(0, 1), 'has_builtin_closets' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_terrace' => mt_rand(0, 1), 'has_box_room' => mt_rand(0, 1), 'has_parking_space' => mt_rand(0, 1), 'has_fireplace' => mt_rand(0, 1), 'has_swimming_pool' => mt_rand(0, 1), 'has_garden' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'rent_country_house';
         $newAd->local_id = $newRentCountryHouse->id;
         $newAd->save();
         $this->command->info('Seeded Rent Country House (id: ' . $newRentCountryHouse->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(600, 2000);
         $deposit = mt_rand(0, 6) ? $deposits[array_rand($deposits)] : null;
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $area_min_for_sale = intval(mt_rand(5, 10) / 10 * $area_usable);
         $has_block = mt_rand(0, 1);
         $block_name = $has_block ? $blocks[array_rand($blocks)] : null;
         $newAd = App\Ad::create();
         $newRentOffice = \App\RentOffice::create(['ad_id' => $newAd->id, 'price' => $price, 'deposit' => $deposit, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'floor_number' => $floors[array_rand($floors)], 'door' => $doors[array_rand($doors)], 'has_block' => $has_block, 'block' => $block_name, 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'area_min_for_sale' => $area_min_for_sale, 'n_floors' => mt_rand(1, 4), 'has_offices_only' => mt_rand(0, 1), 'office_distribution_id' => mt_rand(1, $n_office_distribution_options), 'n_restrooms' => mt_rand(1, 8), 'has_bathrooms' => mt_rand(0, 1), 'has_fire_detectors' => mt_rand(0, 1), 'has_fire_extinguishers' => mt_rand(0, 1), 'has_fire_sprinklers' => mt_rand(0, 1), 'has_fireproof_doors' => mt_rand(0, 1), 'has_emergency_lights' => mt_rand(0, 1), 'has_doorman' => mt_rand(0, 1), 'has_air_conditioning_preinstallation' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_heating' => mt_rand(0, 1), 'has_hot_water' => mt_rand(0, 1), 'has_kitchen' => mt_rand(0, 1), 'has_archive' => mt_rand(0, 1), 'has_double_windows' => mt_rand(0, 1), 'has_suspended_ceiling' => mt_rand(0, 1), 'has_suspended_floor' => mt_rand(0, 1), 'is_handicapped_adapted' => mt_rand(0, 1), 'has_bathrooms_inside' => mt_rand(0, 1), 'is_exterior' => mt_rand(0, 1), 'n_elevators' => mt_rand(1, 8), 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'n_parking_spaces' => mt_rand(10, 50), 'has_steel_door' => mt_rand(0, 1), 'has_security_system' => mt_rand(0, 1), 'has_access_control' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'rent_office';
         $newAd->local_id = $newRentOffice->id;
         $newAd->save();
         $this->command->info('Seeded Rent Office (id: ' . $newRentOffice->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(100000, 1000000);
         $community_cost = mt_rand(0, 5) ? null : mt_rand(10, 300);
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $area_min_for_sale = intval(mt_rand(5, 10) / 10 * $area_usable);
         $has_block = mt_rand(0, 1);
         $block_name = $has_block ? $blocks[array_rand($blocks)] : null;
         $newAd = App\Ad::create();
         $newSellOffice = \App\SellOffice::create(['ad_id' => $newAd->id, 'price' => $price, 'community_cost' => $community_cost, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'floor_number' => $floors[array_rand($floors)], 'door' => $doors[array_rand($doors)], 'has_block' => $has_block, 'block' => $block_name, 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'area_min_for_sale' => $area_min_for_sale, 'n_floors' => mt_rand(1, 4), 'has_offices_only' => mt_rand(0, 1), 'office_distribution_id' => mt_rand(1, $n_office_distribution_options), 'n_restrooms' => mt_rand(1, 8), 'has_bathrooms' => mt_rand(0, 1), 'has_fire_detectors' => mt_rand(0, 1), 'has_fire_extinguishers' => mt_rand(0, 1), 'has_fire_sprinklers' => mt_rand(0, 1), 'has_fireproof_doors' => mt_rand(0, 1), 'has_emergency_lights' => mt_rand(0, 1), 'has_doorman' => mt_rand(0, 1), 'has_air_conditioning_preinstallation' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_heating' => mt_rand(0, 1), 'has_hot_water' => mt_rand(0, 1), 'has_kitchen' => mt_rand(0, 1), 'has_archive' => mt_rand(0, 1), 'has_double_windows' => mt_rand(0, 1), 'has_suspended_ceiling' => mt_rand(0, 1), 'has_suspended_floor' => mt_rand(0, 1), 'is_handicapped_adapted' => mt_rand(0, 1), 'has_bathrooms_inside' => mt_rand(0, 1), 'is_exterior' => mt_rand(0, 1), 'n_elevators' => mt_rand(1, 8), 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'n_parking_spaces' => mt_rand(10, 50), 'has_steel_door' => mt_rand(0, 1), 'has_security_system' => mt_rand(0, 1), 'has_access_control' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'sell_office';
         $newAd->local_id = $newSellOffice->id;
         $newAd->save();
         $this->command->info('Seeded Sell Office (id: ' . $newSellOffice->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(600, 2000);
         $deposit = mt_rand(0, 6) ? $deposits[array_rand($deposits)] : null;
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $has_block = mt_rand(0, 1);
         $block_name = $has_block ? $blocks[array_rand($blocks)] : null;
         $newAd = App\Ad::create();
         $newRentBusiness = \App\RentBusiness::create(['ad_id' => $newAd->id, 'price' => $price, 'is_transfer' => mt_rand(0, 1), 'deposit' => $deposit, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'floor_number' => $floors[array_rand($floors)], 'door' => $doors[array_rand($doors)], 'has_block' => $has_block, 'block' => $block_name, 'category_business_id' => mt_rand(1, $n_business_categories), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'business_distribution_id' => mt_rand(1, $n_business_distribution_options), 'business_facade_id' => mt_rand(1, $n_business_facade_options), 'n_shop_windows' => mt_rand(1, 4), 'business_location_id' => mt_rand(1, $n_business_location_options), 'n_floors' => mt_rand(1, 3), 'n_restrooms' => mt_rand(1, 4), 'last_activity' => $activities[array_rand($activities)], 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'has_archive' => mt_rand(0, 1), 'has_smoke_extractor' => mt_rand(0, 1), 'has_fully_equipped_kitchen' => mt_rand(0, 1), 'has_steel_door' => mt_rand(0, 1), 'has_alarm' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_heating' => mt_rand(0, 1), 'has_security_camera' => mt_rand(0, 1), 'is_corner_located' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'rent_business';
         $newAd->local_id = $newRentBusiness->id;
         $newAd->save();
         $this->command->info('Seeded Rent Business (id: ' . $newRentBusiness->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(100000, 1000000);
         $community_cost = mt_rand(0, 5) ? null : mt_rand(10, 300);
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $has_block = mt_rand(0, 1);
         $block_name = $has_block ? $blocks[array_rand($blocks)] : null;
         $newAd = App\Ad::create();
         $newSellBusiness = \App\SellBusiness::create(['ad_id' => $newAd->id, 'price' => $price, 'community_cost' => $community_cost, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'floor_number' => $floors[array_rand($floors)], 'door' => $doors[array_rand($doors)], 'has_block' => $has_block, 'block' => $block_name, 'category_business_id' => mt_rand(1, $n_business_categories), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'business_distribution_id' => mt_rand(1, $n_business_distribution_options), 'business_facade_id' => mt_rand(1, $n_business_facade_options), 'n_shop_windows' => mt_rand(1, 4), 'business_location_id' => mt_rand(1, $n_business_location_options), 'n_floors' => mt_rand(1, 3), 'n_restrooms' => mt_rand(1, 4), 'last_activity' => $activities[array_rand($activities)], 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'has_archive' => mt_rand(0, 1), 'has_smoke_extractor' => mt_rand(0, 1), 'has_fully_equipped_kitchen' => mt_rand(0, 1), 'has_steel_door' => mt_rand(0, 1), 'has_alarm' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_heating' => mt_rand(0, 1), 'has_security_camera' => mt_rand(0, 1), 'is_corner_located' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'sell_business';
         $newAd->local_id = $newSellBusiness->id;
         $newAd->save();
         $this->command->info('Seeded Sell Business (id: ' . $newSellBusiness->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(10000, 100000);
         $community_cost = mt_rand(0, 5) ? null : mt_rand(10, 100);
         $newAd = App\Ad::create();
         $newSellGarage = \App\SellGarage::create(['ad_id' => $newAd->id, 'price' => $price, 'community_cost' => $community_cost, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'garage_capacity_id' => mt_rand(1, $n_garage_capacity_options), 'is_covered' => mt_rand(0, 1), 'has_automatic_door' => mt_rand(0, 1), 'has_lift' => mt_rand(0, 1), 'has_alarm' => mt_rand(0, 1), 'has_security_camera' => mt_rand(0, 1), 'has_security_guard' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'sell_garage';
         $newAd->local_id = $newSellGarage->id;
         $newAd->save();
         $this->command->info('Seeded Sell Garage (id: ' . $newSellGarage->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(100, 1000);
         $deposit = mt_rand(0, 6) ? $deposits[array_rand($deposits)] : null;
         $newAd = App\Ad::create();
         $newRentGarage = \App\RentGarage::create(['ad_id' => $newAd->id, 'price' => $price, 'deposit' => $deposit, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'garage_capacity_id' => mt_rand(1, $n_garage_capacity_options), 'is_covered' => mt_rand(0, 1), 'has_automatic_door' => mt_rand(0, 1), 'has_lift' => mt_rand(0, 1), 'has_alarm' => mt_rand(0, 1), 'has_security_camera' => mt_rand(0, 1), 'has_security_guard' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'rent_garage';
         $newAd->local_id = $newRentGarage->id;
         $newAd->save();
         $this->command->info('Seeded Rent Garage (id: ' . $newRentGarage->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(50000, 500000);
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $area_min_for_sale = intval(mt_rand(5, 10) / 10) * $area_usable;
         $newAd = App\Ad::create();
         $newSellLand = \App\SellLand::create(['ad_id' => $newAd->id, 'price' => $price, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'category_land_id' => mt_rand(1, $n_land_categories), 'area_total' => $area_land, 'area_building_land' => $area_constructed, 'area_min_for_sale' => $area_min_for_sale, 'is_classified_residential_block' => mt_rand(0, 1), 'is_classified_residential_house' => mt_rand(0, 1), 'is_classified_office' => mt_rand(0, 1), 'is_classified_commercial' => mt_rand(0, 1), 'is_classified_hotel' => mt_rand(0, 1), 'is_classified_industrial' => mt_rand(0, 1), 'is_classified_public_service' => mt_rand(0, 1), 'is_classified_others' => mt_rand(0, 1), 'max_floors_allowed' => mt_rand(0, 5) ? mt_rand(1, 3) : mt_rand(1, 30), 'has_road_access' => mt_rand(0, 1), 'nearest_town_distance_id' => mt_rand(1, $n_nearest_town_distance_options), 'has_water' => mt_rand(0, 1), 'has_electricity' => mt_rand(0, 1), 'has_sewer_system' => mt_rand(0, 1), 'has_natural_gas' => mt_rand(0, 1), 'has_street_lighting' => mt_rand(0, 1), 'has_sidewalks' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'sell_land';
         $newAd->local_id = $newSellLand->id;
         $newAd->save();
         $this->command->info('Seeded Sell Land (id: ' . $newSellLand->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(200, 5000);
         $deposit = mt_rand(0, 6) ? $deposits[array_rand($deposits)] : null;
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $area_min_for_sale = intval(mt_rand(5, 10) / 10 * $area_usable);
         $newAd = App\Ad::create();
         $newRentLand = \App\RentLand::create(['ad_id' => $newAd->id, 'price' => $price, 'deposit' => $deposit, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'category_land_id' => mt_rand(1, $n_land_categories), 'area_total' => $area_land, 'area_building_land' => $area_constructed, 'area_min_for_sale' => $area_min_for_sale, 'is_classified_residential_block' => mt_rand(0, 1), 'is_classified_residential_house' => mt_rand(0, 1), 'is_classified_office' => mt_rand(0, 1), 'is_classified_commercial' => mt_rand(0, 1), 'is_classified_hotel' => mt_rand(0, 1), 'is_classified_industrial' => mt_rand(0, 1), 'is_classified_public_service' => mt_rand(0, 1), 'is_classified_others' => mt_rand(0, 1), 'max_floors_allowed' => mt_rand(0, 5) ? mt_rand(1, 3) : mt_rand(1, 30), 'has_road_access' => mt_rand(0, 1), 'nearest_town_distance_id' => mt_rand(1, $n_nearest_town_distance_options), 'has_water' => mt_rand(0, 1), 'has_electricity' => mt_rand(0, 1), 'has_sewer_system' => mt_rand(0, 1), 'has_natural_gas' => mt_rand(0, 1), 'has_street_lighting' => mt_rand(0, 1), 'has_sidewalks' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'rent_land';
         $newAd->local_id = $newRentLand->id;
         $newAd->save();
         $this->command->info('Seeded Rent Land (id: ' . $newRentLand->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(600, 2000);
         $deposit = mt_rand(0, 6) ? $deposits[array_rand($deposits)] : null;
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $has_block = mt_rand(0, 1);
         $block_name = $has_block ? $blocks[array_rand($blocks)] : null;
         $is_new_development = mt_rand(0, 1);
         $is_new_development_finished = $is_new_development ? mt_rand(0, 1) : 0;
         $newAd = App\Ad::create();
         $newRentApartment = \App\RentApartment::create(['ad_id' => $newAd->id, 'price' => $price, 'deposit' => $deposit, 'is_bank_agency' => mt_rand(0, 1), 'is_state_subsidized' => mt_rand(0, 1), 'is_new_development' => $is_new_development, 'is_new_development_finished' => $is_new_development_finished, 'is_rent_to_own' => mt_rand(0, 1), 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'floor_number' => $floors[array_rand($floors)], 'is_last_floor' => mt_rand(0, 1), 'door' => $doors[array_rand($doors)], 'has_block' => $has_block, 'block' => $block_name, 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'is_regular' => mt_rand(0, 1), 'is_penthouse' => mt_rand(0, 1), 'is_duplex' => mt_rand(0, 1), 'is_studio' => mt_rand(0, 1), 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'n_bedrooms' => mt_rand(1, 5), 'n_bathrooms' => mt_rand(1, 3), 'is_exterior' => mt_rand(0, 1), 'has_equipped_kitchen' => mt_rand(0, 1), 'has_furniture' => mt_rand(0, 1), 'has_elevator' => mt_rand(0, 1), 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'faces_north' => mt_rand(0, 1), 'faces_south' => mt_rand(0, 1), 'faces_east' => mt_rand(0, 1), 'faces_west' => mt_rand(0, 1), 'has_builtin_closets' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_terrace' => mt_rand(0, 1), 'has_box_room' => mt_rand(0, 1), 'has_parking_space' => mt_rand(0, 1), 'has_swimming_pool' => mt_rand(0, 1), 'has_garden' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'rent_apartment';
         $newAd->local_id = $newRentApartment->id;
         $newAd->save();
         $this->command->info('Seeded Rent Apartment (id: ' . $newRentApartment->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(100000, 1000000);
         $community_cost = mt_rand(0, 5) ? null : mt_rand(10, 300);
         $energy_cert_id = mt_rand(1, $n_energy_certification_options);
         $energy_cert_name = \App\EnergyCertification::find($energy_cert_id)->name;
         $energy_performance = in_array($energy_cert_name, $certs) ? $performances[array_rand($performances)] : null;
         $area_land = mt_rand(100, 800);
         $area_constructed = intval(0.6 * $area_land);
         $area_usable = intval(0.8 * $area_constructed);
         $has_block = mt_rand(0, 1);
         $block_name = $has_block ? $blocks[array_rand($blocks)] : null;
         $is_new_development = mt_rand(0, 1);
         $is_new_development_finished = $is_new_development ? mt_rand(0, 1) : 0;
         $newAd = App\Ad::create();
         $newSellApartment = \App\SellApartment::create(['ad_id' => $newAd->id, 'price' => $price, 'community_cost' => $community_cost, 'is_bank_agency' => mt_rand(0, 1), 'is_state_subsidized' => mt_rand(0, 1), 'is_new_development' => $is_new_development, 'is_new_development_finished' => $is_new_development_finished, 'is_rent_to_own' => mt_rand(0, 1), 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'floor_number' => $floors[array_rand($floors)], 'is_last_floor' => mt_rand(0, 1), 'door' => $doors[array_rand($doors)], 'has_block' => $has_block, 'block' => $block_name, 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'is_regular' => mt_rand(0, 1), 'is_penthouse' => mt_rand(0, 1), 'is_duplex' => mt_rand(0, 1), 'is_studio' => mt_rand(0, 1), 'needs_restoration' => mt_rand(0, 1), 'area_constructed' => $area_constructed, 'area_usable' => $area_usable, 'n_bedrooms' => mt_rand(1, 5), 'n_bathrooms' => mt_rand(1, 3), 'is_exterior' => mt_rand(0, 1), 'has_elevator' => mt_rand(0, 1), 'energy_certification_id' => $energy_cert_id, 'energy_performance' => $energy_performance, 'faces_north' => mt_rand(0, 1), 'faces_south' => mt_rand(0, 1), 'faces_east' => mt_rand(0, 1), 'faces_west' => mt_rand(0, 1), 'has_builtin_closets' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_terrace' => mt_rand(0, 1), 'has_box_room' => mt_rand(0, 1), 'has_parking_space' => mt_rand(0, 1), 'has_swimming_pool' => mt_rand(0, 1), 'has_garden' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'sell_apartment';
         $newAd->local_id = $newSellApartment->id;
         $newAd->save();
         $this->command->info('Seeded Sell Apartment (id: ' . $newSellApartment->id . ')');
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $has_block = mt_rand(0, 1);
         $block_name = $has_block ? $blocks[array_rand($blocks)] : null;
         $n_d_b = mt_rand(0, 2);
         $n_1_b = mt_rand(0, 2);
         $n_2_b = mt_rand(0, 2);
         $n_3_b = mt_rand(0, 1);
         $n_4_b = mt_rand(0, 1);
         $min_capacity = $n_d_b * 2 + $n_1_b + $n_2_b * 2 + $n_3_b * 3 + $n_4_b * 4;
         $n_sb = mt_rand(0, 1);
         $n_d_sb = mt_rand(0, 1);
         $n_eb = mt_rand(0, 1);
         $max_capacity = $min_capacity + $n_sb + $n_d_sb * 2 + $n_eb;
         $payment_day = mt_rand(1, $n_payment_day_options);
         $days_before = \App\OptionPaymentDay::find($payment_day)->pluck('name') == 'Días antes de la entrada' ? mt_rand(1, 30) : null;
         $has_booking = mt_rand(0, 2);
         $has_deposit = mt_rand(0, 2);
         $has_cleaning = mt_rand(0, 1);
         if ($has_booking == 1) {
             $booking = mt_rand(1, 100);
         } elseif ($has_booking == 2) {
             $booking = mt_rand(250, 550);
         } else {
             $booking = null;
         }
         if ($has_deposit == 1) {
             $deposit = mt_rand(1, 100);
         } elseif ($has_deposit == 2) {
             $deposit = mt_rand(350, 1550);
         } else {
             $deposit = null;
         }
         $cleaning = !$has_cleaning ? mt_rand(50, 350) : null;
         $area_total = mt_rand(45, 300);
         $area_garden = intval(0.4 * $area_total);
         $area_terrace = intval(0.2 * $area_total);
         $newAd = App\Ad::create();
         $newRentVacation = \App\Lodging::create(['ad_id' => $newAd->id, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'floor_number' => $floors[array_rand($floors)], 'is_last_floor' => mt_rand(0, 1), 'door' => $doors[array_rand($doors)], 'has_block' => $has_block, 'block' => $block_name, 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'surroundings_id' => mt_rand(1, $n_surroundings_options), 'category_lodging_id' => mt_rand(1, $n_lodging_categories), 'has_multiple_lodgings' => mt_rand(0, 1), 'area_total' => $area_total, 'area_garden' => $area_garden, 'area_terrace' => $area_terrace, 'distance_to_beach' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_town_center' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_ski_area' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_golf_course' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_airport' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_supermarket' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_river_or_lake' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_marina' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_horse_riding_area' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_scuba_diving_area' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_train_station' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_bus_station' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_hospital' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'distance_to_hiking_area' => mt_rand(0, 5) ? null : mt_rand(250, 10000), 'n_double_bedroom' => $n_d_b, 'n_two_beds_room' => $n_2_b, 'n_single_bed_room' => $n_1_b, 'n_three_beds_room' => $n_3_b, 'n_four_beds_room' => $n_4_b, 'n_sofa_bed' => $n_sb, 'n_double_sofa_bed' => $n_d_sb, 'n_extra_bed' => $n_eb, 'min_capacity' => $min_capacity, 'max_capacity' => $max_capacity, 'payment_day_id' => $payment_day, 'n_days_before' => $days_before, 'has_booking' => $has_booking, 'booking' => $booking, 'has_deposit' => $has_deposit, 'deposit' => $deposit, 'has_cleaning' => $has_cleaning, 'cleaning' => $cleaning, 'has_included_towels' => mt_rand(0, 1), 'has_included_expenses' => mt_rand(0, 1), 'accepts_cash' => mt_rand(0, 1), 'accepts_transfer' => mt_rand(0, 1), 'accepts_credit_card' => mt_rand(0, 1), 'accepts_paypal' => mt_rand(0, 1), 'accepts_check' => mt_rand(0, 1), 'accepts_western_union' => mt_rand(0, 1), 'accepts_money_gram' => mt_rand(0, 1), 'has_barbecue' => mt_rand(0, 1), 'has_terrace' => mt_rand(0, 1), 'has_private_swimming_pool' => mt_rand(0, 1), 'has_shared_swimming_pool' => mt_rand(0, 1), 'has_indoor_swimming_pool' => mt_rand(0, 1), 'has_private_garden' => mt_rand(0, 1), 'has_shared_garden' => mt_rand(0, 1), 'has_furnished_garden' => mt_rand(0, 1), 'has_parking_space' => mt_rand(0, 1), 'has_playground' => mt_rand(0, 1), 'has_mountain_sights' => mt_rand(0, 1), 'has_sea_sights' => mt_rand(0, 1), 'has_fireplace' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_jacuzzi' => mt_rand(0, 1), 'has_tv' => mt_rand(0, 1), 'has_cable_tv' => mt_rand(0, 1), 'has_internet' => mt_rand(0, 1), 'has_heating' => mt_rand(0, 1), 'has_fan' => mt_rand(0, 1), 'has_cradle' => mt_rand(0, 1), 'has_hairdryer' => mt_rand(0, 1), 'has_dishwasher' => mt_rand(0, 1), 'has_fridge' => mt_rand(0, 1), 'has_oven' => mt_rand(0, 1), 'has_microwave' => mt_rand(0, 1), 'has_coffee_maker' => mt_rand(0, 1), 'has_dryer' => mt_rand(0, 1), 'has_washer' => mt_rand(0, 1), 'has_iron' => mt_rand(0, 1), 'is_smoking_allowed' => mt_rand(0, 1), 'is_pet_allowed' => mt_rand(0, 1), 'has_elevator' => mt_rand(0, 1), 'is_car_recommended' => mt_rand(0, 1), 'is_handicapped_adapted' => mt_rand(0, 1), 'is_out_town_center' => mt_rand(0, 1), 'is_isolated' => mt_rand(0, 1), 'is_nudist_area' => mt_rand(0, 1), 'is_bar_area' => mt_rand(0, 1), 'is_gayfriendly_area' => mt_rand(0, 1), 'is_family_tourism_area' => mt_rand(0, 1), 'is_luxury_area' => mt_rand(0, 1), 'is_charming' => mt_rand(0, 1), 'has_bicycle_rental' => mt_rand(0, 1), 'has_car_rental' => mt_rand(0, 1), 'has_adventure_activities' => mt_rand(0, 1), 'has_kindergarten' => mt_rand(0, 1), 'has_sauna' => mt_rand(0, 1), 'has_tennis_court' => mt_rand(0, 1), 'has_paddle_court' => mt_rand(0, 1), 'has_gym' => mt_rand(0, 1), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'rent_vacation';
         $newAd->local_id = $newRentVacation->id;
         $newAd->save();
         $this->command->info('Seeded Rent Vacation (id: ' . $newRentVacation->id . ')');
         $n_seasons_prices = mt_rand(1, 4);
         for ($j = 0; $j < $n_seasons_prices; $j++) {
             $from_date = \Carbon\Carbon::createFromDate(null, mt_rand(1, 12), 1);
             $to_date = $from_date->addMonths(mt_rand(1, 6));
             $newSeasonPrice = \App\SeasonPrice::create(['n_season' => $j, 'from_date' => $j == 0 ? \Carbon\Carbon::createFromFormat('d/m/Y', '1/1/1900') : $from_date, 'to_date' => $j == 0 ? \Carbon\Carbon::createFromFormat('d/m/Y', '1/1/2999') : $to_date, 'p_one_night' => mt_rand(15, 100), 'p_weekend_night' => mt_rand(30, 200), 'p_one_week' => mt_rand(80, 700), 'p_half_month' => mt_rand(150, 1400), 'p_one_month' => mt_rand(300, 2800), 'p_extra_guest_per_night' => mt_rand(7, 50), 'n_min_nights' => mt_rand(1, 60), 'rent_vacation_id' => $newRentVacation->id]);
             $this->command->info('Seeded Season Price (id: ' . $newSeasonPrice->id . ') for Rent Vacation (id: ' . $newRentVacation->id . ')');
         }
     }
     for ($i = 0; $i < THIS_MANY_ADS; $i++) {
         $location = \App\Geocode::generateRandomLocation();
         $price = mt_rand(250, 700);
         $deposit = mt_rand(0, 6) ? $deposits[array_rand($deposits)] : null;
         $has_block = mt_rand(0, 1);
         $block_name = $has_block ? $blocks[array_rand($blocks)] : null;
         $n_bedrooms = mt_rand(2, 5);
         $n_people = intval($n_bedrooms / 2 + 1);
         $newAd = App\Ad::create();
         $newRentRoom = \App\Room::create(['ad_id' => $newAd->id, 'price' => $price, 'deposit' => $deposit, 'lat' => isset($location['lat']) ? $location['lat'] : '', 'lng' => isset($location['lng']) ? $location['lng'] : '', 'formatted_address' => isset($location['formatted_address']) ? $location['formatted_address'] : '', 'street_number' => isset($location['street_number']) ? $location['street_number'] : '', 'route' => isset($location['route']) ? $location['route'] : '', 'locality' => isset($location['locality']) ? $location['locality'] : '', 'admin_area_lvl2' => isset($location['administrative_area_level_2']) ? $location['administrative_area_level_2'] : '', 'admin_area_lvl1' => isset($location['administrative_area_level_1']) ? $location['administrative_area_level_1'] : '', 'country' => isset($location['country']) ? $location['country'] : '', 'postal_code' => isset($location['postal_code']) ? $location['postal_code'] : '', 'hide_address' => mt_rand(0, 1), 'floor_number' => $floors[array_rand($floors)], 'is_last_floor' => mt_rand(0, 1), 'door' => $doors[array_rand($doors)], 'has_block' => $has_block, 'block' => $block_name, 'residential_area' => mt_rand(0, 5) ? null : $faker->name, 'category_room_id' => mt_rand(1, $n_room_categories), 'area_room' => mt_rand(10, 50), 'n_people' => $n_people, 'n_bedrooms' => $n_bedrooms, 'n_bathrooms' => mt_rand(1, 2), 'current_tenants_gender_id' => mt_rand(1, $n_current_tenants_gender_options), 'is_smoking_allowed' => mt_rand(0, 1), 'is_pet_allowed' => mt_rand(0, 1), 'min_current_tenants_age' => mt_rand(18, 23), 'max_current_tenants_age' => mt_rand(23, 35), 'has_elevator' => mt_rand(0, 1), 'has_furniture' => mt_rand(0, 1), 'has_builtin_closets' => mt_rand(0, 1), 'has_air_conditioning' => mt_rand(0, 1), 'has_internet' => mt_rand(0, 1), 'has_house_keeper' => mt_rand(0, 1), 'tenant_gender_id' => mt_rand(1, $n_tenant_gender_options), 'tenant_occupation_id' => mt_rand(1, $n_tenant_occupation_options), 'tenant_sexual_orientation_id' => mt_rand(1, $n_tenant_sexual_orientation_options), 'tenant_min_stay_id' => mt_rand(1, $n_tenant_min_stay_options), 'description' => $faker->text(1020)]);
         $newAd->local_table = 'rent_room';
         $newAd->local_id = $newRentRoom->id;
         $newAd->save();
         $this->command->info('Seeded Rent Room (id: ' . $newRentRoom->id . ')');
     }
     foreach (\App\Ad::all() as $ad) {
         $n_pics = mt_rand(0, 12);
         for ($i = 0; $i < $n_pics; ++$i) {
             \App\AdPic::create(['ad_id' => $ad->id, 'filename' => 'http://lorempixel.com/640/480/city/Faker']);
             $this->command->info('Seeded Pictures for Ad (id: ' . $ad->id . ')');
         }
     }
 }
Example #3
0
 public function adProfile($id)
 {
     $Ad = Ad::findOrFail($id);
     //specific operation and typology codes for the profile page
     $txt = explode('_', $Ad->local_table, 2);
     switch ($txt[0]) {
         case 'sell':
             switch ($txt[1]) {
                 case 'house':
                     $ad = SellHouse::findOrFail($Ad->local_id);
                     break;
                 case 'apartment':
                     $ad = SellApartment::findOrFail($Ad->local_id);
                     break;
                 case 'country_house':
                     $ad = SellCountryHouse::findOrFail($Ad->local_id);
                     break;
                 case 'business':
                     $ad = SellBusiness::findOrFail($Ad->local_id);
                     break;
                 case 'office':
                     $ad = SellOffice::findOrFail($Ad->local_id);
                     break;
                 case 'garage':
                     $ad = SellGarage::findOrFail($Ad->local_id);
                     break;
                 case 'land':
                     $ad = SellLand::findOrFail($Ad->local_id);
                     break;
             }
             break;
         case 'rent':
             switch ($txt[1]) {
                 case 'house':
                     $ad = RentHouse::findOrFail($Ad->local_id);
                     break;
                 case 'apartment':
                     $ad = RentApartment::findOrFail($Ad->local_id);
                     break;
                 case 'country_house':
                     $ad = RentCountryHouse::findOrFail($Ad->local_id);
                     break;
                 case 'business':
                     $ad = RentBusiness::findOrFail($Ad->local_id);
                     break;
                 case 'office':
                     $ad = RentOffice::findOrFail($Ad->local_id);
                     break;
                 case 'garage':
                     $ad = RentGarage::findOrFail($Ad->local_id);
                     break;
                 case 'land':
                     $ad = RentLand::findOrFail($Ad->local_id);
                     break;
                 case 'room':
                     $ad = Room::findOrFail($Ad->local_id);
                     break;
                 case 'vacation':
                     $ad = Lodging::findOrFail($Ad->local_id);
                     break;
             }
             break;
     }
     switch ($txt[0]) {
         case 'sell':
             $operation = 0;
             break;
         case 'rent':
             $operation = 1;
             break;
     }
     switch ($txt[1]) {
         case 'house':
             $typology = 0;
             $ad->type = CategoryHouse::where('id', $ad->category_house_id)->pluck('name');
             break;
         case 'apartment':
             $typology = 1;
             if ($ad->is_duplex) {
                 $ad->type = 'Dúplex';
             } elseif ($ad->is_penthouse) {
                 $ad->type = 'Ático';
             } elseif ($ad->is_studio) {
                 $ad->type = 'Estudio';
             } else {
                 $ad->type = 'Piso';
             }
             break;
         case 'country_house':
             $typology = 2;
             $ad->type = CategoryCountryHouse::where('id', $ad->category_country_house_id)->pluck('name');
             break;
         case 'business':
             $typology = 3;
             $ad->type = CategoryBusiness::where('id', $ad->category_business_id)->pluck('name');
             $ad->distribution = OptionBusinessDistribution::where('id', $ad->business_distribution_id)->pluck('name');
             $ad->facade = OptionBusinessFacade::where('id', $ad->business_facade_id)->pluck('name');
             $ad->location = OptionBusinessLocation::where('id', $ad->business_location_id)->pluck('name');
             break;
         case 'office':
             $typology = 4;
             $ad->type = 'Oficina';
             $ad->distribution = OptionOfficeDistribution::where('id', $ad->office_distribution_id)->pluck('name');
             break;
         case 'garage':
             $typology = 5;
             $ad->type = 'Garaje';
             $ad->garage_capacity = OptionGarageCapacity::where('id', $ad->garage_capacity_id)->pluck('name');
             break;
         case 'land':
             $typology = 6;
             $ad->type = 'Terreno';
             $ad->category_land = CategoryLand::where('id', $ad->category_land_id)->pluck('name');
             $ad->nearest_town = OptionNearestTownDistance::where('id', $ad->nearest_town_distance_id)->pluck('name');
             break;
         case 'room':
             $typology = 7;
             $ad->type = 'Habitación';
             $ad->category_room = CategoryRoom::where('id', $ad->category_room_id)->pluck('name');
             $ad->min_stay = OptionTenantMinStay::where('id', $ad->tenant_min_stay_id)->pluck('name');
             $ad->current_gender = OptionCurrentTenantsGender::where('id', $ad->current_tenants_gender_id)->pluck('name');
             $ad->gender = OptionTenantGender::where('id', $ad->tenant_gender_id)->pluck('name');
             $ad->occupation = OptionTenantOccupation::where('id', $ad->tenant_occupation_id)->pluck('name');
             $ad->sexual_orientation = OptionTenantSexualOrientation::where('id', $ad->tenant_sexual_orientation_id)->pluck('name');
             break;
         case 'vacation':
             $typology = 8;
             $ad->type = CategoryLodging::where('id', $ad->category_lodging_id)->pluck('name');
             $ad->surroundings = OptionSurroundings::where('id', $ad->surroundings_id)->pluck('name');
             $ad->min_price_per_night = \DB::select(\DB::raw("\n                  SELECT MIN(t2.p_one_month) as min_price_per_night\n                  FROM rent_vacation AS t1\n                  LEFT JOIN vacation_season_price AS t2 ON t1.id = t2.rent_vacation_id\n                  WHERE t1.id = ?;\n                "), [$ad->id]);
             $ad->season_prices = SeasonPrice::where('rent_vacation_id', $ad->id)->get();
             $ad->payment_day = OptionPaymentDay::where('id', $ad->payment_day_id)->pluck('name');
             break;
     }
     return view('ad', compact('ad', 'operation', 'typology'));
 }