예제 #1
0
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     CurrencyTranslation::saved(function ($translation) {
         $this->preventEmptyTranslation($translation);
     });
     CountryTranslation::saved(function ($translation) {
         $this->preventEmptyTranslation($translation);
     });
     BottleSizeTranslation::saved(function ($translation) {
         $this->preventEmptyTranslation($translation);
     });
     ConsumedReasonTranslation::saved(function ($translation) {
         $this->preventEmptyTranslation($translation);
     });
     RegionTypeTranslation::saved(function ($translation) {
         $this->preventEmptyTranslation($translation);
     });
     RegionTranslation::saved(function ($translation) {
         $this->preventEmptyTranslation($translation);
     });
     RegionTranslation::saving(function ($translation) {
         $this->isNativeTranslation($translation);
     });
     CountryTranslation::saving(function ($translation) {
         $this->isNativeTranslation($translation);
     });
     CurrencyTranslation::saving(function ($translation) {
         $this->getSortAs($translation);
     });
     CountryTranslation::saving(function ($translation) {
         $this->getSortAs($translation);
     });
     BottleSizeTranslation::saving(function ($translation) {
         $this->getSortAs($translation);
     });
     ConsumedReasonTranslation::saving(function ($translation) {
         $this->getSortAs($translation);
     });
     RegionTypeTranslation::saving(function ($translation) {
         $this->getSortAs($translation);
     });
     RegionTranslation::saving(function ($translation) {
         $this->getSortAs($translation);
     });
 }
예제 #2
0
파일: testroutes.php 프로젝트: kitbs/vinfo
    $countries = Vinfo\Country::get()->lists('name')->toArray();
    // collator_sort_with_sort_keys ($coll, $countries);
    foreach ($countries as &$country) {
        $country = ['name' => $country, 'pinyin' => Overtrue\Pinyin\Pinyin::trans($country), 'en' => collator_get_sort_key($en, $country), 'coll' => collator_get_sort_key($coll, $country)];
    }
    $countries = new Illuminate\Support\Collection($countries);
    $countries = $countries->sortBy('coll');
    foreach ($countries as $country) {
        echo $country['pinyin'] . '<br>';
    }
    return ' ';
    dd($countries);
});
Route::get('/test/region-names', function () {
    die;
    $translations = RegionTranslation::with('region.country')->get();
    //->where('id', '>', 640)->limit(10)
    foreach ($translations as $translation) {
        $locale = str_replace('-', '_', $translation->locale);
        $country = $translation->region->country->code;
        $languages = Territory::getLanguages($country, 'of', true);
        $languages[] = $locale . '_' . $country;
        $translation->is_native = in_array($locale, $languages);
        $translation->save();
    }
    return $translations;
    $regions = Region::whereTranslation('name', 'Wienn')->get();
    foreach ($regions as $region) {
        $names = ['en' => ['name' => 'Vienna'], 'de' => ['name' => 'Wien']];
        $region->fill($names);
        $region->save();