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


PHP Facades\Setting类代码示例

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


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

示例1: handle

 /**
  * Run the app is setup middleware.
  *
  * We're verifying that Cachet is correctly setup. If it is, then we're
  * redirecting the user to the dashboard so they can use Cachet.
  *
  * @param \Illuminate\Routing\Route $route
  * @param \Closure                  $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Setting::get('app_name')) {
         return Redirect::to('dashboard');
     }
     return $next($request);
 }
开发者ID:minhkiller,项目名称:Cachet,代码行数:18,代码来源:AppIsSetup.php

示例2: compose

 /**
  * Index page view composer.
  *
  * @param \Illuminate\Contracts\View\View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $isEnabled = (bool) Setting::get('enable_subscribers', false);
     $mailAddress = env('MAIL_ADDRESS', false);
     $mailFrom = env('MAIL_NAME', false);
     $view->withSubscribersEnabled($isEnabled && $mailAddress && $mailFrom);
 }
开发者ID:practico,项目名称:Cachet,代码行数:14,代码来源:AppComposer.php

示例3: boot

 /**
  * Boot the service provider.
  */
 public function boot()
 {
     $appDomain = $appLocale = null;
     try {
         // Get app custom configuration.
         $appDomain = Setting::get('app_domain');
         $appLocale = Setting::get('app_locale');
         // Set the Segment.com settings.
         if (Setting::get('app_track')) {
             $segmentRepository = $this->app->make('CachetHQ\\Cachet\\Segment\\RepositoryInterface');
             $this->app->config->set('segment.write_key', $segmentRepository->fetch());
         }
         // Setup Cors.
         $allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
         $allowedOrigins[] = Setting::get('app_domain');
         // Add our allowed domains too.
         if ($allowedDomains = Setting::get('allowed_domains')) {
             $domains = explode(',', $allowedDomains);
             foreach ($domains as $domain) {
                 $allowedOrigins[] = $domain;
             }
         } else {
             $allowedOrigins[] = env('APP_URL');
         }
         $this->app->config->set('cors.paths.api/v1/*.allowedOrigins', $allowedOrigins);
     } catch (Exception $e) {
         // Don't throw any errors, we may not be setup yet.
     }
     // Override default app values.
     $this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
     $this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
     // Set custom lang.
     $this->app->translator->setLocale($appLocale);
 }
开发者ID:hd-deman,项目名称:Cachet,代码行数:37,代码来源:ConfigServiceProvider.php

示例4: boot

 /**
  * Boot the service provider.
  *
  * @return void
  */
 public function boot()
 {
     $appDomain = $appLocale = $appTimezone = null;
     try {
         // Get app custom configuration.
         $appDomain = Setting::get('app_domain');
         $appLocale = Setting::get('app_locale');
         $appTimezone = Setting::get('app_timezone');
         // Setup Cors.
         $allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
         $allowedOrigins[] = Setting::get('app_domain');
         // Add our allowed domains too.
         if ($allowedDomains = Setting::get('allowed_domains')) {
             $domains = explode(',', $allowedDomains);
             foreach ($domains as $domain) {
                 $allowedOrigins[] = $domain;
             }
         } else {
             $allowedOrigins[] = $this->app->config->get('app.url');
         }
         $this->app->config->set('cors.paths.api/v1/*.allowedOrigins', $allowedOrigins);
     } catch (Exception $e) {
         // Don't throw any errors, we may not be setup yet.
     }
     // Override default app values.
     $this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
     $this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
     $this->app->config->set('cachet.timezone', $appTimezone ?: $this->app->config->get('cachet.timezone'));
     // Set custom lang.
     $this->app->translator->setLocale($appLocale);
 }
开发者ID:reginaldojunior,项目名称:Cachet,代码行数:36,代码来源:ConfigServiceProvider.php

示例5: env

 /**
  * Is the subscriber functionality enabled and configured.
  *
  * @return bool
  */
 function subscribers_enabled()
 {
     $isEnabled = Setting::get('enable_subscribers', false);
     $mailAddress = env('MAIL_ADDRESS', false);
     $mailFrom = env('MAIL_NAME', false);
     return $isEnabled && $mailAddress && $mailFrom;
 }
开发者ID:n0mer,项目名称:Cachet,代码行数:12,代码来源:helpers.php

示例6: getValuesByHour

 /**
  * Returns the sum of all values a metric has by the hour.
  *
  * @param int $hour
  *
  * @return int
  */
 public function getValuesByHour($hour)
 {
     $dateTimeZone = SettingFacade::get('app_timezone');
     $dateTime = (new Date())->setTimezone($dateTimeZone)->sub(new DateInterval('PT' . $hour . 'H'));
     $hourInterval = $dateTime->format('YmdH');
     if (Config::get('database.default') === 'mysql') {
         if (!isset($this->calc_type) || $this->calc_type == self::CALC_SUM) {
             $value = (int) $this->points()->whereRaw('DATE_FORMAT(created_at, "%Y%m%d%H") = ' . $hourInterval)->groupBy(DB::raw('HOUR(created_at)'))->sum('value');
         } elseif ($this->calc_type == self::CALC_AVG) {
             $value = (int) $this->points()->whereRaw('DATE_FORMAT(created_at, "%Y%m%d%H") = ' . $hourInterval)->groupBy(DB::raw('HOUR(created_at)'))->avg('value');
         }
     } else {
         // Default metrics calculations.
         if (!isset($this->calc_type) || $this->calc_type == self::CALC_SUM) {
             $queryType = 'sum(metric_points.value)';
         } elseif ($this->calc_type == self::CALC_AVG) {
             $queryType = 'avg(metric_points.value)';
         } else {
             $queryType = 'sum(metric_points.value)';
         }
         $query = DB::select("select {$queryType} as aggregate FROM metrics JOIN metric_points ON metric_points.metric_id = metrics.id WHERE metric_points.metric_id = {$this->id} AND to_char(metric_points.created_at, 'YYYYMMDDHH24') = :timestamp GROUP BY to_char(metric_points.created_at, 'H')", ['timestamp' => $hourInterval]);
         if (isset($query[0])) {
             $value = $query[0]->aggregate;
         } else {
             $value = 0;
         }
     }
     if ($value === 0 && $this->default_value != $value) {
         return $this->default_value;
     }
     return $value;
 }
开发者ID:nguyentamvinhlong,项目名称:Cachet,代码行数:39,代码来源:Metric.php

示例7:

 /**
  * Is the subscriber functionality enabled and configured.
  *
  * @return bool
  */
 function subscribers_enabled()
 {
     $isEnabled = Setting::get('enable_subscribers', false);
     $mailAddress = Config::get('mail.from.address', false);
     $mailFrom = Config::get('mail.from.name', false);
     return $isEnabled && $mailAddress && $mailFrom;
 }
开发者ID:guduchango,项目名称:Cachet,代码行数:12,代码来源:helpers.php

示例8: fetch

 /**
  * Returns the segment write key.
  *
  * @return string
  */
 public function fetch()
 {
     $writeKey = null;
     try {
         // Firstly, does the setting exist?
         if (null === ($writeKey = Setting::get('segment_write_key'))) {
             // No, let's go fetch it.
             $writeKey = $this->repository->fetch();
             Setting::set('segment_write_key', $writeKey);
         } else {
             // It does, but how old is it?
             $setting = SettingModel::where('name', 'segment_write_key')->first();
             // It's older than an hour, let's refresh
             if ($setting->updated_at->lt(Carbon::now()->subHour())) {
                 $writeKey = $this->repository->fetch();
                 // Update the setting. This is done manual to make sure updated_at is overwritten.
                 $setting->value = $writeKey;
                 $setting->updated_at = Carbon::now();
                 $setting->save();
             }
         }
     } catch (QueryException $e) {
         // Just return it until we're setup.
         $writeKey = $this->repository->fetch();
     }
     return $writeKey;
 }
开发者ID:hd-deman,项目名称:Cachet,代码行数:32,代码来源:CacheRepository.php

示例9: compose

 /**
  * Index page view composer.
  *
  * @param \Illuminate\Contracts\View\View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $isEnabled = (bool) Setting::get('enable_subscribers', false);
     $mailAddress = env('MAIL_ADDRESS', false);
     $mailFrom = env('MAIL_NAME', false);
     $view->withSubscribersEnabled($isEnabled && $mailAddress && $mailFrom);
     $view->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')));
 }
开发者ID:ramirors,项目名称:Cachet,代码行数:15,代码来源:AppComposer.php

示例10: handle

 /**
  * We're verifying that subscribers is both enabled and configured.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $isEnabled = Setting::get('enable_subscribers', false);
     $mailAddress = env('MAIL_ADDRESS', false);
     $mailFrom = env('MAIL_NAME', false);
     if (!($isEnabled && $mailAddress && $mailFrom)) {
         return Redirect::route('status-page');
     }
     return $next($request);
 }
开发者ID:hd-deman,项目名称:Cachet,代码行数:18,代码来源:SubscribersConfigured.php

示例11: handle

 /**
  * Handle the report maintenance command.
  *
  * @param \CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand $command
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function handle(ReportMaintenanceCommand $command)
 {
     // TODO: Add validation to scheduledAt
     $scheduledAt = Date::createFromFormat('d/m/Y H:i', $command->timestamp, Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone'));
     $maintenanceEvent = Incident::create(['name' => $command->name, 'message' => $command->message, 'scheduled_at' => $scheduledAt, 'status' => 0, 'visible' => 1]);
     // Notify subscribers.
     if ($command->notify) {
         event(new MaintenanceWasScheduledEvent($maintenanceEvent));
     }
     return $maintenanceEvent;
 }
开发者ID:practico,项目名称:Cachet,代码行数:18,代码来源:ReportMaintenanceCommandHandler.php

示例12: compose

 /**
  * Bind data to the view.
  *
  * @param \Illuminate\Contracts\View\View $view
  */
 public function compose(View $view)
 {
     $view->withThemeBackgroundColor(Setting::get('style_background_color'));
     $view->withThemeTextColor(Setting::get('style_text_color'));
     $viewData = $view->getData();
     $themeView = array_only($viewData, preg_grep('/^theme/', array_keys($viewData)));
     $hasThemeSettings = array_filter($themeView, function ($data) {
         return $data != null;
     });
     $view->withThemeSetup(!empty($hasThemeSettings));
 }
开发者ID:RetinaInc,项目名称:Cachet,代码行数:16,代码来源:ThemeComposer.php

示例13: getSignup

 /**
  * Handle the signup with invite.
  *
  * @param string|null $code
  *
  * @return \Illuminate\View\View
  */
 public function getSignup($code = null)
 {
     if (is_null($code)) {
         throw new NotFoundHttpException();
     }
     $invite = Invite::where('code', '=', $code)->first();
     if (!$invite || $invite->claimed()) {
         throw new BadRequestHttpException();
     }
     return View::make('signup')->withPageTitle(Setting::get('app_name'))->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')))->withCode($invite->code)->withUsername(Binput::old('username'))->withEmail(Binput::old('emai', $invite->email));
 }
开发者ID:blumtech,项目名称:Cachet,代码行数:18,代码来源:SignupController.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     try {
         if (!Setting::get('app_name')) {
             return Redirect::to('setup');
         }
     } catch (Exception $e) {
         return Redirect::to('setup');
     }
     return $next($request);
 }
开发者ID:CMNatic,项目名称:Cachet,代码行数:19,代码来源:ReadyForUse.php

示例15: compose

 /**
  * Metrics view composer.
  *
  * @param \Illuminate\Contracts\View\View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $metrics = null;
     $metricData = [];
     if ($displayMetrics = Setting::get('display_graphs')) {
         $metrics = Metric::where('display_chart', 1)->get();
         $metrics->map(function ($metric) use(&$metricData) {
             $metricData[$metric->id] = ['today' => $this->metricRepository->listPointsToday($metric), 'week' => $this->metricRepository->listPointsForWeek($metric), 'month' => $this->metricRepository->listPointsForMonth($metric)];
         });
     }
     $view->withDisplayMetrics($displayMetrics)->withMetrics($metrics)->withMetricData($metricData);
 }
开发者ID:guduchango,项目名称:Cachet,代码行数:19,代码来源:MetricsComposer.php


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