当前位置: 首页>>代码示例>>PHP>>正文


PHP Language::getAllByPriority方法代码示例

本文整理汇总了PHP中app\Language::getAllByPriority方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::getAllByPriority方法的具体用法?PHP Language::getAllByPriority怎么用?PHP Language::getAllByPriority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Language的用法示例。


在下文中一共展示了Language::getAllByPriority方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compose

 public function compose($view)
 {
     // Application language
     $view->with('appLanguage', $appLanguage = app('language'));
     // All languages (for implementing https://support.google.com/webmasters/answer/189077)
     $url = parse_url(Request::url());
     $domain = preg_replace('/^[a-z][a-z]\\./', '', $url['host']);
     $languages = Language::getAllByPriority();
     foreach ($languages as &$l) {
         // Regenerate URL
         $url['host'] = $l->code . '.' . $domain;
         $l->url = http_build_url($url);
     }
     $view->with('allLanguages', $languages);
     // All languages but current one
     $view->with('allLanguagesButCurrent', $languages->filter(function ($l) use($appLanguage) {
         return $l->id != $appLanguage->id;
     }));
 }
开发者ID:nerea91,项目名称:laravel,代码行数:19,代码来源:ApplicationLanguageComposer.php

示例2: makeSecondarySections

 /**
  * Define the secondary sections of the menu.
  *
  * @param  User $user User to checked permissions against
  *
  * @return array (of Menu\Node)
  */
 public static function makeSecondarySections(User $user)
 {
     // Section: Change application language
     $currentLanguage = app('language');
     $allLanguages = Language::getAllByPriority();
     $changeLanguage = new Node($currentLanguage);
     if ($allLanguages->count() > 1) {
         $newLanguages = new Flat(_('Change language'));
         foreach ($allLanguages as $l) {
             if ($l->id != $currentLanguage->id) {
                 // Do not add current language
                 $newLanguages->addChild(new Link(route('language.set', ['code' => $l->code]), $l->name));
             }
         }
         $changeLanguage->addChild($newLanguages);
     }
     // Section: User panel
     $userPanel = new Node($user->getName());
     $userPanel->addChild(new Link(route('user.options'), _('Options')));
     $userPanel->addChild(new Link(route('logout'), _('Logout'), ['class' => 'button alert expanded', 'style' => 'height:auto;']));
     return compact('changeLanguage', 'userPanel');
 }
开发者ID:nerea91,项目名称:laravel,代码行数:29,代码来源:AdminPanelMenuComposer.php


注:本文中的app\Language::getAllByPriority方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。