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


PHP Facades\Lang类代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Lang的典型用法代码示例。如果您正苦于以下问题:PHP Lang类的具体用法?PHP Lang怎么用?PHP Lang使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: convert

 public function convert()
 {
     $validator = Validator::make(Input::all(), ['from' => 'required|min:3|max:3', 'to' => 'required|min:3|max:3']);
     if ($validator->fails()) {
         return response()->json([$validator->errors()])->setStatusCode(422, 'Validation Failed');
     }
     $from = Currency::find(Input::get('from'));
     $to = Currency::find(Input::get('to'));
     $precision = (int) Config::get('laravel-currency.laravel-currency.precision');
     $multiplier = pow(10, (int) Config::get('laravel-currency.laravel-currency.precision'));
     $amount = (double) Input::get('amount') ?: 1;
     if ($from == $to) {
         return response()->json($amount);
     }
     $amount = round($amount * $multiplier);
     if ($from && ($from->base == Input::get('to') || $from->base == $to->code)) {
         return response()->json(round($amount / $from->price, $precision));
     }
     if ($to && ($to->base == Input::get('from') || $to->base == $from->code)) {
         return response()->json(round($amount * $to->price / pow($multiplier, 2), $precision));
     }
     if (!$from || !$to) {
         return response()->json(['error' => Lang::get('currency.error.not_found')])->setStatusCode(404, 'Currency Not Found');
     }
     if ($from->base !== $to->base) {
         throw new Exception('Cannot convert currencies with different bases.');
     }
     return response()->json(round($amount / $from->price * $to->price / $multiplier, $precision));
 }
开发者ID:Rolice,项目名称:LaravelCurrency,代码行数:29,代码来源:CurrencyController.php

示例2: setPassword

 public function setPassword()
 {
     if ($this->request->method() === 'GET') {
         return $this->showForm(['token' => $this->request->input('token')]);
     }
     $person = Person::findByEmail($this->request->input('email'));
     if (!$person->isValid()) {
         return $this->showForm(['error' => Lang::get('boomcms::recover.errors.invalid_email'), 'token' => $this->request->input('token')]);
     }
     $tokens = $this->app['auth.password.tokens'];
     $token = $tokens->exists($person, $this->request->input('token'));
     if (!$token) {
         return $this->showForm(['error' => Lang::get('boomcms::recover.errors.invalid_token'), 'token' => $this->request->input('token')]);
     }
     if ($this->request->input('password1') != $this->request->input('password2')) {
         return $this->showForm(['error' => Lang::get('boomcms::recover.errors.password_mismatch'), 'token' => $this->request->input('token')]);
     }
     if ($this->request->input('password1') && $this->request->input('password2')) {
         $tokens->delete($token);
         $tokens->deleteExpired();
         $person->setEncryptedPassword($this->auth->hash($this->request->input('password1')));
         Person::save($person);
         $this->auth->login($person);
         return redirect('/');
     } else {
         return $this->showForm(['error' => Lang::get('boomcms::recover.errors.password_mismatch'), 'token' => $this->request->input('token')]);
     }
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:28,代码来源:Recover.php

示例3: handle

 /**
  * @param Request $request
  * @param Closure $next
  */
 public function handle($request, Closure $next)
 {
     Lang::setFallback(self::getDefault());
     $setLocale = Session::get('setLocale');
     //flash data
     if (Config::get('app.locale_use_cookie')) {
         if ($setLocale) {
             Session::set('locale', $setLocale);
         }
         if (Session::has('locale')) {
             App::setLocale(Session::get('locale'));
         } else {
             self::autoDetect();
         }
     } else {
         if (Config::get('app.locale_use_url')) {
             if ($setLocale) {
                 self::setLocaleURLSegment($setLocale);
             } else {
                 $lang = self::getLocaleFromURL();
                 if ($lang) {
                     App::setLocale($lang);
                 } else {
                     if ($request->segment(1) != 'locale') {
                         //ignore set-locale URL
                         self::autoDetect();
                         self::setLocaleURLSegment(self::get());
                     }
                 }
             }
         }
     }
     View::share('lang', self::get());
 }
开发者ID:hramose,项目名称:laravel5-adminLTE-1,代码行数:38,代码来源:language.php

示例4: runCrawler

 public function runCrawler()
 {
     switch (Input::get('action')) {
         case 'recreateurls':
             foreach (Page::all() as $page) {
                 $page->url = Page::getUrl($page->id);
                 $page->save();
             }
             die("Recreated URL:s");
             break;
         case 'crawl':
             Crawler::url(Input::get('crawl_url'), Input::get('crawl_found_links') ? true : false);
             if (Input::get('crawl_convert')) {
                 Crawler::createPages();
             }
             break;
         case 'convertToPages':
             Crawler::convertToPages();
             break;
         default:
             return Response::json('Invalid action', 400);
             break;
     }
     if (Request::ajax()) {
         return Response::json(Lang::get('cms::m.crawler-done'), 200);
     } else {
         return Redirect::route('crawler')->with('flash_notice', Lang::get('cms::m.crawler-done'));
     }
 }
开发者ID:cednet,项目名称:laravel-cms-addon,代码行数:29,代码来源:CrawlerController.php

示例5: index

 public function index()
 {
     $title = Lang::get('lang.destinations');
     $destinations = Destinations::where('active', '=', 1)->where('isDomestic', '=', '1')->orderBy('ordering')->paginate(6);
     $destinations->setPath('destinations');
     return view('destinations.index', compact('destinations', 'title'));
 }
开发者ID:asker-hr,项目名称:laravel3,代码行数:7,代码来源:DestinationsController.php

示例6: notificationPayload

 /**
  * @return array
  */
 public function notificationPayload()
 {
     $message = Lang::get('heartbeats.recovered_message', ['job' => $this->heartbeat->name]);
     $url = route('projects', ['id' => $this->heartbeat->project_id]);
     $payload = ['attachments' => [['fallback' => $message, 'text' => $message, 'color' => 'good', 'fields' => [['title' => Lang::get('notifications.project'), 'value' => sprintf('<%s|%s>', $url, $this->heartbeat->project->name), 'short' => true]], 'footer' => Lang::get('app.name'), 'ts' => time()]]];
     return $payload;
 }
开发者ID:rebelinblue,项目名称:deployer,代码行数:10,代码来源:HeartbeatRecovered.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $locale = config('app.locale');
     $adminLocale = config('typicms.admin_locale');
     $locales = config('translatable.locales');
     // If locale is present in app.locales…
     if (in_array(Input::get('locale'), $locales)) {
         // …store locale in session
         Session::put('locale', Input::get('locale'));
     }
     // Set app.locale
     config(['app.locale' => Session::get('locale', $locale)]);
     // Set Translator locale to typicms.admin_locale config
     Lang::setLocale($adminLocale);
     $localesForJS = [];
     foreach ($locales as $key => $locale) {
         $localesForJS[] = ['short' => $locale, 'long' => trans('global.languages.' . $locale)];
     }
     // Set Locales to JS.
     JavaScript::put(['_token' => csrf_token(), 'encrypted_token' => Crypt::encrypt(csrf_token()), 'adminLocale' => $adminLocale, 'locales' => $localesForJS, 'locale' => config('app.locale')]);
     // set curent user preferences to Config
     if ($request->user()) {
         $prefs = $request->user()->preferences;
         config(['typicms.user' => $prefs]);
     }
     return $next($request);
 }
开发者ID:vizo,项目名称:Core,代码行数:34,代码来源:Admin.php

示例8: boot

 /**
  * Boot the service provider
  *
  * @return void
  */
 public function boot()
 {
     //Register the packages assets
     $this->package('mscharl/pretty-error-page');
     //add a language namespace to allow customizing of translations
     Lang::addNamespace('pretty-error-page-customized', app_path('lang/packages/mscharl/pretty-error-page'));
 }
开发者ID:mscharl,项目名称:pretty-error-page,代码行数:12,代码来源:PrettyErrorPageServiceProvider.php

示例9: getLogout

 /**
  * Logout the user
  * 
  * @return Redirect
  */
 public function getLogout()
 {
     //Logout the user
     Auth::logout();
     //Redirect to login page
     return Redirect::to('admin/login')->with('success', Lang::get('firadmin::admin.messages.logout-success'));
 }
开发者ID:firalabs,项目名称:firadmin,代码行数:12,代码来源:LoginController.php

示例10: auth

 /**
  * Ensure user is logged in
  *
  * @return
  */
 public function auth()
 {
     if (!$this->auth->check()) {
         $redirect = '?redirect=' . urlencode(Request::path());
         return Redirect::to('/auth/login' . $redirect)->with('error_message', Lang::get('messages.login_access_denied'));
     }
 }
开发者ID:Ajaxman,项目名称:SaleBoss,代码行数:12,代码来源:SimpleAccessFilter.php

示例11: 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;
 }
开发者ID:SocietyCMS,项目名称:Modules,代码行数:30,代码来源:ModuleManager.php

示例12: latest

 public function latest()
 {
     if ($this->isLoggedIn && $this->request->has('personal') && $this->request->get('personal') == 'true') {
         $isCached = false;
         $bans = $this->repository->getPersonalBans($this->user->settings()->playerIds());
     } else {
         $isCached = Cache::has('bans.latest');
         $bans = $this->repository->getLatestBans();
     }
     if ($this->request->has('type') && $this->request->get('type') == 'rss') {
         $feed = Feed::make();
         $feed->title = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title'));
         $feed->description = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title'));
         $feed->setDateFormat('datetime');
         $feed->link = URL::to('api/bans/latest?type=rss');
         $feed->lang = 'en';
         foreach ($bans as $ban) {
             $title = sprintf('%s banned for %s', $ban['player']['SoldierName'], $ban['record']['record_message']);
             $view = View::make('system.rss.ban_entry_content', ['playerId' => $ban['player']['PlayerID'], 'playerName' => $ban['player']['SoldierName'], 'banreason' => $ban['record']['record_message'], 'sourceName' => $ban['record']['source_name'], 'sourceId' => $ban['record']['source_id'], 'banReason' => $ban['record']['record_message']]);
             $feed->add($title, $ban['record']['source_name'], $ban['player']['profile_url'], $ban['ban_startTime'], $title, $view->render());
         }
         return $feed->render('atom');
     }
     return MainHelper::response(['cols' => Lang::get('dashboard.bans.columns'), 'bans' => $bans], null, null, null, $isCached, true);
 }
开发者ID:BP4U,项目名称:BFAdminCP,代码行数:25,代码来源:BansController.php

示例13: show

 public function show(Tag $tag)
 {
     $posts = Tag::find($tag->id)->posts()->latest()->get();
     $title = Lang::get('tags.index.title', ['tag' => $tag->name]);
     $header = Lang::get('tags.index.header', ['tag' => $tag->name]);
     return view('posts.index', compact('posts', 'title', 'header'));
 }
开发者ID:itainathaniel,项目名称:blog,代码行数:7,代码来源:TagsController.php

示例14: __construct

 public function __construct()
 {
     parent::__construct(Lang::get('oauth.unauthorized_client'), 14002);
     $this->httpStatusCode = 401;
     $errorType = class_basename($this);
     $this->errorType = snake_case(strtr($errorType, array('Exception' => '')));
 }
开发者ID:safarishi,项目名称:laravel4api,代码行数:7,代码来源:UnauthorizedClientException.class.php

示例15: getFeedAssessments

 public function getFeedAssessments()
 {
     $feed = $this->metabans->feed();
     $assessments = $this->metabans->assessments();
     $feed_assessments = ['feed' => $feed, 'assessments' => $assessments];
     return MainHelper::response($feed_assessments + ['locales' => Lang::get('common.metabans')], null, null, null, false, true);
 }
开发者ID:BP4U,项目名称:BFAdminCP,代码行数:7,代码来源:MetabansController.php


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