/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \App\CategoryBusiness::create(['name' => 'Local comercial']);
     \App\CategoryBusiness::create(['name' => 'Nave industrial']);
     \App\CategoryCountryHouse::create(['name' => 'Finca rústica']);
     \App\CategoryCountryHouse::create(['name' => 'Castillo']);
     \App\CategoryCountryHouse::create(['name' => 'Palacio']);
     \App\CategoryCountryHouse::create(['name' => 'Masía']);
     \App\CategoryCountryHouse::create(['name' => 'Cortijo']);
     \App\CategoryCountryHouse::create(['name' => 'Casa rural']);
     \App\CategoryCountryHouse::create(['name' => 'Casa de pueblo']);
     \App\CategoryCountryHouse::create(['name' => 'Casa terrera']);
     \App\CategoryCountryHouse::create(['name' => 'Torre']);
     \App\CategoryCountryHouse::create(['name' => 'Caserón']);
     \App\CategoryHouse::create(['name' => 'Casa']);
     \App\CategoryHouse::create(['name' => 'Chalet pareado']);
     \App\CategoryHouse::create(['name' => 'Chalet adosado']);
     \App\CategoryLand::create(['name' => 'Urbano']);
     \App\CategoryLand::create(['name' => 'Urbanizable']);
     \App\CategoryLand::create(['name' => 'No urbanizable']);
     \App\CategoryLodging::create(['name' => 'Apartamento']);
     //apartamento, ático, estudio...
     \App\CategoryLodging::create(['name' => 'Casa']);
     //casa rural, chalet adosado...
     \App\CategoryLodging::create(['name' => 'Villa']);
     //Chalet independiente con jardín por los cuatro costados
     \App\CategoryRoom::create(['name' => 'Piso compartido']);
     \App\CategoryRoom::create(['name' => 'Casa compartida']);
 }
Exemplo n.º 2
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'));
 }