本文整理汇总了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;
}));
}
示例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');
}