本文整理匯總了PHP中Illuminate\Support\Facades\Lang::has方法的典型用法代碼示例。如果您正苦於以下問題:PHP Lang::has方法的具體用法?PHP Lang::has怎麽用?PHP Lang::has使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\Lang
的用法示例。
在下文中一共展示了Lang::has方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: login
/**
* Handle a login request to the application.
* Requires $this->usernameField, password, remember request fields.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function login(Request $request)
{
$this->validate($request, [$this->usernameField => 'required', 'password' => 'required']);
// Check whether this controller is using ThrottlesLogins trait
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
$credentials = $request->only($this->usernameField, 'password');
// Try to authenticate using username or NIM
if (Auth::attempt(['username' => $request[$this->usernameField], 'password' => $request['password']], $request->has('remember')) || Auth::attempt(['nim' => $request[$this->usernameField], 'password' => $request['password']], $request->has('remember'))) {
// Authentication successful
if ($throttles) {
$this->clearLoginAttempts($request);
}
return redirect()->intended($this->redirectLogin);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if ($throttles) {
$this->incrementLoginAttempts($request);
}
$failedLoginMessage = Lang::has('auth.failed') ? Lang::get('auth.failed') : 'These credentials do not match our records.';
return redirect()->back()->withInput($request->only($this->usernameField, 'remember'))->withErrors([$this->usernameField => $failedLoginMessage]);
}
示例2: get
/**
* Return a modules.
*
* @return \Illuminate\Support\Collection
*/
public function get(Module $module)
{
$moduleName = $module->getName();
if (Lang::has("{$moduleName}::module.title")) {
$module->localname = Lang::get("{$moduleName}::module.title");
} else {
$module->localname = $module->getStudlyName();
}
if (Lang::has("{$moduleName}::module.description")) {
$module->description = Lang::get("{$moduleName}::module.description");
}
$package = $this->packageVersion->getPackageInfo("societycms/module-{$moduleName}");
if (isset($package->name) && strpos($package->name, '/')) {
$module->vendor = explode('/', $package->name)[0];
}
$module->version = isset($package->version) ? $package->version : 'N/A';
$module->versionUrl = '#';
$module->isCore = $this->isCoreModule($module);
if (isset($package->source->url)) {
$packageUrl = str_replace('.git', '', $package->source->url);
$module->versionUrl = $packageUrl . '/tree/' . $package->dist->reference;
}
$module->license = $package->license;
return $module;
}
示例3: t
/**
* Get a string from language file.
*
* @param string $string
* @param string $default
* @param array $parameters
* @return mixed
*/
function t($string, $default = null, $parameters = [])
{
if (Lang::has($string)) {
return Lang::get($string, $parameters);
}
return $default;
}
示例4: testDefaultPlaceholderTextsAreDefined
public function testDefaultPlaceholderTextsAreDefined()
{
$types = ['asset', 'location', 'link', 'text', 'html', 'feature', 'library', 'linkset', 'slideshow', 'timestamp'];
foreach ($types as $type) {
$langKey = "boomcms::chunks.{$type}.default";
$this->assertTrue(Lang::has($langKey), $type);
}
}
示例5: has
public function has($message, $package = '')
{
$found = Lang::has($message);
if ($package != '') {
$found = $found || Lang::has($package . '::' . $message);
}
return $found || Lang::has('translation::' . $message);
}
示例6: getObjectTransValue
/**
* Funtion to set ObjectTrans variable
*
* @access public
* @param array $parameters
* @param string $objectTrans
* @return string
*/
public static function getObjectTransValue($parameters, $objectTrans)
{
if (Lang::has($parameters['package'] . '::pulsar.' . $objectTrans)) {
return $parameters['package'] . '::pulsar.' . $objectTrans;
} elseif (Lang::has('pulsar::pulsar.' . $objectTrans)) {
return 'pulsar::pulsar.' . $objectTrans;
}
}
示例7: key
/**
* Evalutes column name
*
* @param $key
* @return mixed
*/
public function key($key)
{
if (Lang::has('strings.' . $key)) {
return Lang::get('strings.' . $key);
} else {
return $key;
}
}
示例8: has
public function has($key, $locale = null)
{
if (Lang::has($this->namespaced($key, true), $locale)) {
return true;
} else {
return Lang::has($this->namespaced($key), $locale);
}
}
示例9: options
public static function options()
{
$options = [];
foreach (Config::get('boomcms.settingsManagerOptions') as $name => $type) {
$langPrefix = "boomcms::settings-manager.{$name}.";
$options[] = ['name' => $name, 'label' => Lang::get("{$langPrefix}_label"), 'type' => $type, 'value' => Settings::get($name), 'info' => Lang::has("{$langPrefix}_info") ? Lang::get("{$langPrefix}_info") : ''];
}
usort($options, function ($a, $b) {
return $a['label'] < $b['label'] ? -1 : 1;
});
return $options;
}
示例10: __call
/**
* Create localizated Route
*
* @param string $name [ get, post, put, delete, patch ]
* @param array $args
* @return \Illuminate\Routing\Router
*/
public function __call($name, $args)
{
$methods = ['get', 'post', 'put', 'delete', 'patch'];
if (in_array($name, $methods)) {
list($uri, $as, $uses, $locale) = $args;
if (Lang::has($uri)) {
$uri = Lang::get($uri, [], $locale);
}
if ($locale) {
$as = "{$locale}.{$as}";
}
return $this->app['router']->{$name}($uri, ['as' => $as, 'uses' => $uses]);
}
}
示例11: check
public function check($controller_suffix = 'Controller')
{
$routeAction = Route::currentRouteAction();
preg_match_all('/([a-z0-9A-Z]+\\\\)?(\\w+)@(\\w+)/', $routeAction, $matchs);
$controller_full = $matchs[2][0];
//類名
$controller = str_replace($controller_suffix, '', $controller_full);
$action = $matchs[3][0];
//方法名
//不需要認證的模塊,則放行
if (isset($this->config['AUTH_LOGIN_NO'][$controller]) && ($this->config['AUTH_LOGIN_NO'][$controller] == '*' || in_array($action, $this->config['AUTH_LOGIN_NO'][$controller]))) {
return true;
}
//沒有登陸跳轉到登陸頁麵
if (!$this->checkLogin()) {
//todo
return $this->noLogin();
}
$power = $this->getRolePower(Session::get($this->config['AUTH_SESSION_PREFIX'] . 'role_id'));
//臨時的,記得刪除-1 todo
//$power = -1;
if ($power == -1) {
return true;
} else {
$privilege = Lang::has('privilege') ? Lang::get('privilege') : array();
$controller = str_replace('Controller', '', $controller);
if ($privilege) {
if (isset($privilege[$controller]['power_rule']['module_hidden'])) {
if ($privilege[$controller]['power_rule']['module_hidden'] == 0) {
if (isset($privilege[$controller][$action])) {
if (isset($privilege[$controller]['power_rule'][$action]) && $privilege[$controller]['power_rule'][$action] == 1) {
return true;
} else {
if (isset($power[$controller][$action]) && $power[$controller][$action] == -1) {
return true;
}
}
} else {
//沒有設置$privilege[$controller][$action]一律通過
return true;
}
} elseif ($privilege[$controller]['power_rule']['module_hidden'] == 1) {
return true;
}
}
}
}
return $this->noPower();
}
示例12: sendGet
/**
* Get the page navigation by working.
*
* @return array
*/
protected function sendGet()
{
$model = $this->model;
$pages = $model::where('show_nav', '=', true)->get(['nav_title', 'slug', 'icon'])->toArray();
foreach ($pages as $key => $page) {
$pages[$key]['slug'] = 'pages/' . $page['slug'];
if (Lang::has('navigation.' . $page['nav_title'])) {
$pages[$key]['title'] = trans('navigation.' . $page['nav_title']);
} else {
$pages[$key]['title'] = $page['nav_title'];
}
unset($pages[$key]['nav_title']);
}
return $pages;
}
示例13: listTranslated
/**
* Create a list based on localisation
*
* @param string $prefix The localization prefix/file
* @param string $key The key column in the resulting array
* @param string $value The value column in the resulting array
* @return Array The array containing the list
*
* @author Zaïd Sadhoe <zaid@10forward.nl>
*/
public static function listTranslated($prefix = '', $key = 'id', $value = 'name')
{
$results = self::lists($value, $key);
foreach ($results as $key => &$value) {
if (Lang::has($prefix . $key)) {
$value = Lang::get($prefix . $key);
} else {
if (Lang::has($prefix . $value)) {
$value = Lang::get($prefix . $value);
}
}
}
asort($results);
return $results;
}
示例14: getPageText
/**
* Get a translated string for an error page.
* Either a specific one if defined or a generic if not.
*
* @param $key
* @param $code
* @param array $options
*
* @return string
*/
public static function getPageText($key, $code, $options = [])
{
$cSpecificKey = "pretty-error-page-customized::{$code}.{$key}";
$cGenericKey = "pretty-error-page-customized::generic.{$key}";
$specificKey = "pretty-error-page::{$code}.{$key}";
$genericKey = "pretty-error-page::generic.{$key}";
if (Lang::has($cSpecificKey)) {
return Lang::get($cSpecificKey, $options);
} else {
if (Lang::has($cGenericKey)) {
return Lang::get($cGenericKey, $options);
} else {
if (Lang::has($specificKey)) {
return Lang::get($specificKey, $options);
}
}
}
return Lang::get($genericKey, $options);
}
示例15: getLockoutErrorMessage
/**
* Get the login lockout error message.
*
* @param int $seconds
* @return string
*/
protected function getLockoutErrorMessage($seconds)
{
return Lang::has('auth.throttle') ? Lang::get('auth.throttle', ['seconds' => $seconds]) : 'Too many login attempts. Account Blocked, an email has been sent to ' . Input::get('email') . " to reset password";
}