/**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     // set the supported languages, as defined in the admin panel
     // falls back to the configuration in laravellocalization.supportedLocales
     if (count(DB::select("SHOW TABLES LIKE 'languages'"))) {
         Config::set('laravellocalization.supportedLocales', \Dick\TranslationManager\Models\Language::getActiveLanguagesArray());
     }
     parent::boot($router);
     //
 }
Beispiel #2
0
 /**
  * Used with AJAX in the list view (datatables) to show extra information about that row that didn't fit in the table.
  * It defaults to showing all connected translations and their CRUD buttons.
  *
  * It's enabled by:
  * - setting the $crud['details_row'] variable to true;
  * - adding the details route for the entity; ex: Route::get('page/{id}/details', 'PageCrudController@showDetailsRow');
  */
 public function showDetailsRow($id)
 {
     // get the info for that entry
     $model = $this->crud['model'];
     $this->data['entry'] = $model::find($id);
     $this->data['entry']->addFakes($this->getFakeColumnsAsArray());
     $this->data['original_entry'] = $this->data['entry'];
     $this->data['crud'] = $this->crud;
     if (property_exists($model, 'translatable')) {
         $this->data['translations'] = $this->data['entry']->translations();
         // create a list of languages the item is not translated in
         $this->data['languages'] = \Dick\TranslationManager\Models\Language::all();
         $this->data['languages_already_translated_in'] = $this->data['entry']->translationLanguages();
         $this->data['languages_to_translate_in'] = $this->data['languages']->diff($this->data['languages_already_translated_in']);
         $this->data['languages_to_translate_in'] = $this->data['languages_to_translate_in']->reject(function ($item) {
             return $item->abbr == \Lang::locale();
         });
     }
     // load the view from /resources/views/vendor/dick/crud/ if it exists, otherwise load the one in the package
     return $this->firstViewThatExists('vendor.dick.crud.details_row', 'crud::details_row', $this->data);
 }
<ul class="nav nav-pills">
    @foreach($page->allTranslations() as $key => $translation)
    	<?php 
$lang = \Dick\TranslationManager\Models\Language::findByAbbr($translation->translation_lang);
?>
        <li role="presentation"
			@if(App::getLocale() == $lang->abbr)
				class="active"
			@endif
        >
            <a rel="alternate" hreflang="{{$lang->abbr}}" href="{{ url($lang->abbr.'/'.$translation->slug) }}">
                {{{ $lang->native }}}
            </a>
        </li>
    @endforeach
</ul>