Exemplo n.º 1
0
 private function getDropdowns()
 {
     $countries = Country::withTranslation()->whereIsActive()->orderByTranslation('sortas')->get()->lists('name', 'id');
     $region_types = RegionType::withTranslation()->orderByTranslation('sortas')->get()->lists('name', 'id');
     view()->share('countries', $countries);
     view()->share('region_types', $region_types);
 }
Exemplo n.º 2
0
 private function getDropdowns()
 {
     $countries = Country::withTranslation()->whereIsActive()->orderByTranslation('sortas')->get()->lists('name', 'id');
     $languages = Language::orderBy('name')->get()->lists('name', 'id');
     $currencies = Currency::withTranslation()->orderByTranslation('sortas')->get()->lists('name', 'id');
     view()->share('countries', $countries);
     view()->share('languages', $languages);
     view()->share('currencies', $currencies);
 }
Exemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('regions')->delete();
     $countries = Country::whereIsWine()->whereIsActive()->get();
     foreach ($countries as $country) {
         $country = Region::create(['name' => $country->name, 'region_type_id' => 1, 'country_id' => $country->id]);
         $country->makeRoot();
     }
 }
Exemplo n.º 4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('wineries')->truncate();
     $faker = Faker\Factory::create();
     for ($i = 1; $i <= 50; $i++) {
         $winery = new Winery();
         $winery->name = ucwords(implode(' ', $faker->words(3)));
         $winery->address = $faker->address();
         $winery->country_id = Country::whereCode($faker->countryCode())->first();
         $winery->save();
     }
 }
Exemplo n.º 5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->delete();
     $users = [['id' => 1, 'name' => 'System', 'email' => 'system@vinfo', 'password' => bcrypt('password'), 'is_admin' => true], ['id' => 2, 'name' => 'Admin', 'email' => 'admin@vinfo', 'password' => bcrypt('password'), 'is_admin' => true], ['id' => 3, 'name' => 'User', 'email' => 'user@vinfo', 'password' => bcrypt('password'), 'is_admin' => false]];
     $country = Country::whereCode('GB')->first();
     $language = Language::whereCode('en-GB')->first();
     $currency = Currency::whereCode('GBP')->first();
     foreach ($users as $userData) {
         $user = new User();
         $user->fill($userData);
         $user->country()->associate($country);
         $user->language()->associate($language);
         $user->currency()->associate($currency);
         $user->save();
     }
 }
Exemplo n.º 6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('countries')->delete();
     $locales = Config::get('translatable.locales');
     // $locales = get_locales(true);
     $countries = Territory::getCountries('en');
     $producing = ['AL', 'AM', 'AR', 'AT', 'AU', 'AZ', 'BA', 'BE', 'BG', 'BO', 'BR', 'BY', 'CA', 'CH', 'CL', 'CN', 'CU', 'CY', 'CZ', 'DE', 'DZ', 'EE', 'EG', 'ES', 'ET', 'FR', 'GB', 'GE', 'GR', 'HR', 'HU', 'IL', 'IT', 'JO', 'JP', 'KG', 'KZ', 'LB', 'LI', 'LT', 'LU', 'LV', 'LY', 'MA', 'MD', 'ME', 'MG', 'MK', 'MT', 'MX', 'NZ', 'PA', 'PE', 'PT', 'PY', 'RE', 'RO', 'RS', 'RU', 'SI', 'SK', 'SY', 'TJ', 'TM', 'TN', 'TR', 'UA', 'US', 'UY', 'UZ', 'VN', 'ZA', 'ZW', 'CSHH', 'CSXX', 'SUHH', 'YUCS'];
     foreach ($countries as $code => $void) {
         $country = ['code' => $code, 'is_wine' => in_array($code, $producing)];
         $nameEn = Territory::getName($code, 'en');
         foreach ($locales as $key => $locale) {
             if (is_array($locale)) {
                 $country[$key] = ['name' => Territory::getName($code, $key)];
                 foreach ($locale as $countryLocale) {
                     $name = Territory::getName($code, $key . '-' . $countryLocale);
                     if ($name != $country[$key]['name'] && $name != $nameEn) {
                         $country[$key . '-' . $countryLocale] = ['name' => $name];
                     }
                 }
             } else {
                 $name = Territory::getName($code, $locale);
                 if ($name != $nameEn) {
                     $country[$locale] = ['name' => $name];
                 }
             }
         }
         $country = Country::create($country);
         $langs = Territory::getLanguages($code, 'of', true);
         $langs = array_map(function ($lang) {
             return str_replace('_', '-', $lang);
         }, $langs);
         $langs = array_diff($langs, get_locales(true));
         foreach ($langs as $lang) {
             $name = Territory::getName($code, str_replace('-', '_', $lang));
             $translation = $country->getNewTranslation($lang);
             $translation->name = $name;
             $translation->country_id = $country->id;
             $translation->save();
         }
     }
     $countries = ['CSHH' => 'Czechoslovakia', 'CSXX' => 'Serbia and Montenegro', 'SUHH' => 'Soviet Union', 'YUCS' => 'Yugoslavia'];
     foreach ($countries as $code => $name) {
         $country = ['code' => $code, 'is_wine' => in_array($code, $producing), 'en' => ['name' => $name]];
         $country = Country::create($country);
     }
 }
Exemplo n.º 7
0
 public function languageAndCurrencyByCountry($id)
 {
     $country = Country::find($id);
     if ($country) {
         $code = $country->code;
         $languages = PunicTerritory::getLanguages($code, 'of', true);
         $languages = array_map(function ($value) {
             return str_replace('_', '-', $value);
         }, $languages);
         $allLanguages = Language::lists('code')->toArray();
         $languages = array_intersect(array_merge((array) $languages, ['en']), $allLanguages);
         $language = head($languages);
         $allCurrencies = Currency::lists('code')->toArray();
         $currencies = PunicCurrency::getCurrencyForTerritory($code);
         $currencies = array_intersect(array_merge((array) $currencies, ['GBP']), $allCurrencies);
         $currency = head($currencies);
         $language = Language::whereCode($language)->first();
         $currency = Currency::whereCode($currency)->first();
         return ['language_id' => $language->id, 'currency_id' => $currency->id];
     } else {
         return response('error', 404);
     }
 }
Exemplo n.º 8
0
 private function getCountryResults()
 {
     $query = Country::whereIsActive();
     $transformer = new CountryTransformer();
     return [$transformer, $query];
 }