Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['room_type_id' => 'required|numeric', 'room_no' => 'required|unique:rooms,room_no']);
     $input = $request->all();
     Room::create($input);
     return redirect('/room');
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 5; $i++) {
         Room::create(['name' => 'Room ' . $faker->colorName, 'icon' => 'star', 'color' => 'blue', 'daycare_id' => 1]);
     }
 }
Example #3
0
 /**
  * POST /api/create-room
  */
 public function createRoom()
 {
     // Get all data send in post
     $subscribeFormData = Request::all();
     // Create rules for the validator
     $validator = Validator::make($subscribeFormData, ['user_name' => 'required', 'user_email' => 'required|email|unique:users,email', 'user_password' => 'required', 'partner_name' => 'required', 'partner_email' => 'required|email|unique:users,email', 'partner_password' => 'required']);
     // If validator fails return a 404 response
     if ($validator->fails()) {
         return Response::json(['status_code' => 404, 'errors' => $validator->errors()->all()], 404);
     }
     // If user use same email for user/partner ...
     if ($subscribeFormData['user_email'] == $subscribeFormData['partner_email']) {
         return Response::json(['status_code' => 404, 'errors' => ["Votre email doit être différent de celui de votre partenaire."]], 404);
     }
     // Create user
     $user = User::create(['name' => ucfirst($subscribeFormData['user_name']), 'email' => $subscribeFormData['user_email'], 'password' => Hash::make($subscribeFormData['user_password']), 'activation_token' => uniqid()]);
     // Create partner
     $partner = User::create(['name' => ucfirst($subscribeFormData['partner_name']), 'email' => $subscribeFormData['partner_email'], 'password' => Hash::make($subscribeFormData['partner_password']), 'is_partner' => true, 'activation_token' => uniqid()]);
     // Create room
     $room = Room::create(['token' => Room::generateToken(), 'user_id' => $user->id, 'partner_id' => $partner->id]);
     if ($user && $partner && $room) {
         // Add room ID
         User::where('id', '=', $user->id)->update(['room_id' => $room->id]);
         User::where('id', '=', $partner->id)->update(['room_id' => $room->id]);
         // Send email registration
         event(new UserHasRegistered(User::find($user->id), false));
         event(new UserHasRegistered(User::find($partner->id), true));
         // Return response
         return Response::json(['status_code' => 200, 'success' => "Merci de valider vos adresses email pour activer vos comptes."]);
     }
 }
Example #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $daycare_id = Auth::user()->daycare->id;
     $room = Room::create(array_merge($request->all(), compact('daycare_id')));
     //        return message()->with(compact('room'))
     //            ->success(Config::get('messages.rooms.store_success'));
 }
 public function addRoom(Request $request)
 {
     //add new room
     $room = new Room();
     $room = $request->all();
     Room::create($room);
     return redirect()->route('listroom_com');
 }
Example #6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make([$request->all(), 'nom_salle' => $request->nom_salle, 'capacite_salle' => $request->capacite_salle], ['nom_salle' => 'required', 'capacite_salle' => 'required|integer'], ['nom_salle.required' => "le nom de la salle est requis", 'capacite_salle.required' => "la capacité de salle est requis", 'capacite_salle.integer' => "le nombre doit etre un entier"]);
     if ($validator->passes()) {
         Room::create(['nom_salle' => $request->nom_salle, 'capacite_salle' => $request->capacite_salle, 'color' => '#525252', 'user_id' => \Auth::user()->id]);
         return redirect()->action('StatisticsController@gestion')->with('success', 'Informations bien enregistrées');
     } else {
         return redirect()->back()->withErrors($validator);
     }
 }
 /**
  * GHet user by ID
  *
  * @return Response
  */
 public function store()
 {
     /**
      * Création d'une room simple, Ajout d'un users_room automatiquement, voir controller users méthod store
      */
     // Remplissage des data, pour l'insertion
     $data = \Input::get('data');
     \App\Room::create($data);
     return response()->json('Création de la room avec succès', 200);
 }
Example #8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $codes = ["1-305", "1-315", "2-260", "2-269", "2-286", "2-102", "2-103", "Forum", "Chapel"];
     foreach ($codes as $code) {
         try {
             Room::create(['code' => $code]);
         } catch (Exception $e) {
             print $e->getMessage();
         }
     }
 }
Example #9
0
 public function store(Request $request)
 {
     try {
         $room = Room::create($request->all());
         flash()->success('Room created!');
         $code = $room->code;
         return redirect()->route('timeslot.add_room', compact('room'));
     } catch (\Illuminate\Database\QueryException $e) {
         flash()->error('Room already exists!');
         return redirect(route('room.index'));
     }
 }
 public function run()
 {
     DB::table('rooms')->delete();
     //Small Room
     Room::create(['name' => '#101', 'type' => Room::TYPE_AFFORDABLE, 'pax' => 5, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_AFFORDABLE]);
     Room::create(['name' => '#102', 'type' => Room::TYPE_AFFORDABLE, 'pax' => 5, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_AFFORDABLE]);
     Room::create(['name' => '#103', 'type' => Room::TYPE_AFFORDABLE, 'pax' => 5, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_AFFORDABLE]);
     Room::create(['name' => '#104', 'type' => Room::TYPE_AFFORDABLE, 'pax' => 5, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_AFFORDABLE]);
     //End Small Room
     //Big Room
     Room::create(['name' => '#105', 'type' => Room::TYPE_MIDDLE_CLASS, 'pax' => 10, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_MIDDLE_CLASS]);
     Room::create(['name' => '#106', 'type' => Room::TYPE_MIDDLE_CLASS, 'pax' => 10, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_MIDDLE_CLASS]);
     Room::create(['name' => '#107', 'type' => Room::TYPE_MIDDLE_CLASS, 'pax' => 10, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_MIDDLE_CLASS]);
     Room::create(['name' => '#108', 'type' => Room::TYPE_MIDDLE_CLASS, 'pax' => 10, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_MIDDLE_CLASS]);
     Room::create(['name' => '#109', 'type' => Room::TYPE_MIDDLE_CLASS, 'pax' => 10, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_MIDDLE_CLASS]);
     Room::create(['name' => '#201', 'type' => Room::TYPE_MIDDLE_CLASS, 'pax' => 10, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_MIDDLE_CLASS]);
     Room::create(['name' => '#202', 'type' => Room::TYPE_MIDDLE_CLASS, 'pax' => 10, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_MIDDLE_CLASS]);
     Room::create(['name' => '#203', 'type' => Room::TYPE_MIDDLE_CLASS, 'pax' => 10, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_MIDDLE_CLASS]);
     //End Big Room
     //V.I.P.
     Room::create(['name' => '#204', 'type' => Room::TYPE_VIP, 'pax' => 2, 'availability' => Room::AVAILABILITY_VACANT, 'price' => Room::PRICE_TYPE_VIP]);
     //End V.I.P.
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Room::create(['name' => 'Keuken', 'i2c_id' => '0x20', 'tempsensorpath' => '28-0000074c4490', 'relaispath' => 17, 'activeduration' => 60]);
     Room::create(['name' => 'Zaal', 'i2c_id' => '0x24', 'tempsensorpath' => '28-0000074bd9cd', 'relaispath' => 27, 'activeduration' => 30]);
 }
 /**
  * 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 #13
0
 public function doNewAd()
 {
     $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'];
             }
         }
     }
     //create new Ad ID
     $newAd = Ad::create();
     $input['ad_id'] = $newAd->id;
     //associate pictures to the new Ad ID
     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 all the details of the ad in its specific table
     switch ($input['operation']) {
         case '0':
             //sell
             switch ($input['typology']) {
                 case '0':
                     //apartment
                     $new = SellApartment::create($input);
                     $table = 'sell_apartment';
                     break;
                 case '1':
                     //house
                     $new = SellHouse::create($input);
                     $table = 'sell_house';
                     break;
                 case '2':
                     //country house
                     $new = SellCountryHouse::create($input);
                     $table = 'sell_country_house';
                     break;
                 case '3':
                     //office
                     $new = SellOffice::create($input);
                     $table = 'sell_office';
                     break;
                 case '4':
                     //business
                     $new = SellBusiness::create($input);
                     $table = 'sell_business';
                     break;
                 case '5':
                     //garage
                     $new = SellGarage::create($input);
                     $table = 'sell_garage';
                     break;
                 case '6':
                     //land
                     $new = SellLand::create($input);
                     $table = 'sell_land';
                     break;
             }
             break;
         case '1':
             //rent
             switch ($input['typology']) {
                 case '0':
                     //apartment
                     $new = RentApartment::create($input);
                     $table = 'rent_apartment';
                     break;
                 case '1':
                     //house
                     $new = RentHouse::create($input);
                     $table = 'rent_house';
                     break;
                 case '2':
                     //country house
                     $new = RentCountryHouse::create($input);
                     $table = 'rent_country_house';
                     break;
                 case '3':
                     //office
                     $new = RentOffice::create($input);
                     $table = 'rent_office';
                     break;
                 case '4':
                     //business
                     $new = RentBusiness::create($input);
                     $table = 'rent_business';
                     break;
                 case '5':
                     //garage
                     $new = RentGarage::create($input);
                     $table = 'rent_garage';
                     break;
                 case '6':
                     //land
                     $new = RentLand::create($input);
                     $table = 'rent_land';
                     break;
                 case '7':
                     //vacation (lodging)
                     $new = Lodging::create($input);
                     $table = 'rent_vacation';
                     //associate prices to new 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' => $new->id]);
                         }
                     }
                     break;
                 case '8':
                     //room
                     $new = Room::create($input);
                     $table = 'rent_room';
                     break;
             }
             break;
     }
     //save local table and ID as ad fields
     if (isset($new) && isset($table)) {
         $newAd->local_table = $table;
         $newAd->local_id = $new->id;
         $newAd->save();
     }
     //return success to admin dashboard
     if (isset($new->id)) {
         return redirect('dashboard')->with('success', ['Stitle' => 'Nuevo anuncio', 'Smsg' => 'Su nuevo anuncio ha sido creado satisfactoriamente.']);
     }
     return redirect('dashboard')->with('error', ['Etitle' => 'Nuevo anuncio', 'Emsg' => 'Se produjo un error al tratar de crear un nuevo anuncio. Si el problema persiste póngase en contacto con el Servicio Técnico de la aplicación.']);
 }
Example #14
0
 /**
  * Store a csv created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function import(Request $request)
 {
     if ($request->file('csv-file')->isValid()) {
         $csv_file = $request->file('csv-file');
         if ("text/csv" == $csv_file->getClientMimeType()) {
             $dest_path = storage_path('temp');
             $file_name = time() . '_' . str_replace(" ", "_", $csv_file->getClientOriginalName());
             $csv_file->move($dest_path, $file_name);
             $fname = $dest_path . '/' . $file_name;
             $file = fopen($fname, "r");
             $flash_message = [];
             $flash_error = 0;
             while (!feof($file)) {
                 $tmp_data = fgetcsv($file);
                 $item['building_id'] = !empty($tmp_data[0]) ? $tmp_data[0] : '';
                 $building = Building::where('code', '=', $item['building_id'])->first();
                 if ($building) {
                     $item['building_id'] = $building->id;
                 }
                 $item['code'] = !empty($tmp_data[1]) ? $tmp_data[1] : '';
                 $item['name'] = !empty($tmp_data[2]) ? $tmp_data[2] : '';
                 $item['capacity'] = !empty($tmp_data[3]) ? $tmp_data[3] : '0';
                 $item['feature_id'] = !empty($tmp_data[4]) ? $tmp_data[4] : '1';
                 $v = Validator::make($item, ['building_id' => 'required|integer', 'code' => 'required|unique:rooms|max:20', 'name' => 'required|max:254', 'capacity' => 'integer|min:5', 'feature_id' => 'integer|min:1']);
                 if (!$v->fails()) {
                     Room::create($item);
                     $flash_message['success'][] = '[' . $item['code'] . '] ' . $item['name'];
                 } else {
                     $flash_error++;
                     $flash_message['error'] = $flash_error;
                 }
             }
             \Session::flash('flash_message', $flash_message);
             fclose($file);
             chmod($fname, 0777);
             unlink($fname);
         }
     }
     return redirect('/rooms');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Requests\RoomRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\RoomRequest $request)
 {
     $room = Room::create($request->only(['name', 'activeduration', 'tempsensorpath', 'relaispath', 'temperature']));
     return $room->fresh(['timeslots']);
 }