本文整理汇总了PHP中CachetHQ\Cachet\Facades\Setting类的典型用法代码示例。如果您正苦于以下问题:PHP Setting类的具体用法?PHP Setting怎么用?PHP Setting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Setting类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: handle
/**
* Run the has setting middleware.
*
* We're verifying that the given setting exists in our database. If it
* doesn't, then we're sending the user to the setup page so that they can
* complete the installation of Cachet on their server.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
$settingName = $this->getSettingName($request);
try {
if (!Setting::get($settingName)) {
return Redirect::to('setup');
}
} catch (Exception $e) {
return Redirect::to('setup');
}
return $next($request);
}
开发者ID:guduchango,项目名称:Cachet,代码行数:24,代码来源:HasSetting.php
示例17: showIndex
/**
* Returns the rendered Blade templates.
*
* @return \Illuminate\View\View
*/
public function showIndex()
{
$today = Date::now();
$startDate = Date::now();
segment_page('Status Page');
// Check if we have another starting date
if (Binput::has('start_date')) {
try {
// If date provided is valid
$oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
segment_track('Status Page', ['start_date' => $oldDate->format('Y-m-d')]);
// If trying to get a future date fallback to today
if ($today->gt($oldDate)) {
$startDate = $oldDate;
}
} catch (Exception $e) {
// Fallback to today
}
}
$metrics = null;
if ($displayMetrics = Setting::get('display_graphs')) {
$metrics = Metric::where('display_chart', 1)->get();
}
$daysToShow = Setting::get('app_incident_days') ?: 7;
$incidentDays = range(0, $daysToShow - 1);
$dateTimeZone = Setting::get('app_timezone');
$incidentVisiblity = Auth::check() ? 0 : 1;
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use($dateTimeZone) {
return (new Date($incident->created_at))->setTimezone($dateTimeZone)->toDateString();
});
// Add in days that have no incidents
foreach ($incidentDays as $i) {
$date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
if (!isset($allIncidents[$date->toDateString()])) {
$allIncidents[$date->toDateString()] = [];
}
}
// Sort the array so it takes into account the added days
$allIncidents = $allIncidents->sortBy(function ($value, $key) {
return strtotime($key);
}, SORT_REGULAR, true)->all();
// Scheduled maintenance code.
$scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
// Component & Component Group lists.
$usedComponentGroups = Component::where('group_id', '>', 0)->groupBy('group_id')->lists('group_id');
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
$ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
$canPageBackward = Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() != 0;
return View::make('index', ['componentGroups' => $componentGroups, 'ungroupedComponents' => $ungroupedComponents, 'displayMetrics' => $displayMetrics, 'metrics' => $metrics, 'allIncidents' => $allIncidents, 'scheduledMaintenance' => $scheduledMaintenance, 'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')), 'canPageForward' => (bool) $today->gt($startDate), 'canPageBackward' => $canPageBackward, 'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(), 'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(), 'pageTitle' => Setting::get('app_name') . ' Status']);
}
开发者ID:2bj,项目名称:Cachet,代码行数:55,代码来源:HomeController.php
示例18: compose
/**
* Bind data to the view.
*
* @param \Illuminate\Contracts\View\View $view
*
* @return void
*/
public function compose(View $view)
{
// Theme colors.
$view->withThemeBackgroundColor(Setting::get('style_background_color', '#F0F3F4'));
$view->withThemeBackgroundFills(Setting::get('style_background_fills', '#FFFFFF'));
$view->withThemeTextColor(Setting::get('style_text_color', '#333333'));
$view->withThemeReds(Setting::get('style_reds', '#ff6f6f'));
$view->withThemeBlues(Setting::get('style_blues', '#3498db'));
$view->withThemeGreens(Setting::get('style_greens', '#7ED321'));
$view->withThemeYellows(Setting::get('style_yellows', '#F7CA18'));
$view->withThemeOranges(Setting::get('style_oranges', '#FF8800'));
$view->withThemeMetrics(Setting::get('style_metrics', '#0dccc0'));
$view->withThemeLinks(Setting::get('style_links', '#7ED321'));
}
开发者ID:practico,项目名称:Cachet,代码行数:21,代码来源:ThemeComposer.php
示例19: showIndex
/**
* Displays the status page.
*
* @return \Illuminate\View\View
*/
public function showIndex()
{
$today = Date::now();
$startDate = Date::now();
// Check if we have another starting date
if (Binput::has('start_date')) {
try {
// If date provided is valid
$oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
// If trying to get a future date fallback to today
if ($today->gt($oldDate)) {
$startDate = $oldDate;
}
} catch (Exception $e) {
// Fallback to today
}
}
$daysToShow = Setting::get('app_incident_days', 0) - 1;
if ($daysToShow < 0) {
$daysToShow = 0;
$incidentDays = [];
} else {
$incidentDays = range(0, $daysToShow);
}
$dateTimeZone = Setting::get('app_timezone');
$incidentVisiblity = Auth::check() ? 0 : 1;
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use($dateTimeZone) {
// If it's scheduled, get the scheduled at date.
if ($incident->is_scheduled) {
return (new Date($incident->scheduled_at))->setTimezone($dateTimeZone)->toDateString();
}
return (new Date($incident->created_at))->setTimezone($dateTimeZone)->toDateString();
});
// Add in days that have no incidents
foreach ($incidentDays as $i) {
$date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
if (!isset($allIncidents[$date->toDateString()])) {
$allIncidents[$date->toDateString()] = [];
}
}
// Sort the array so it takes into account the added days
$allIncidents = $allIncidents->sortBy(function ($value, $key) {
return strtotime($key);
}, SORT_REGULAR, true)->all();
return View::make('index')->withDaysToShow($daysToShow)->withAllIncidents($allIncidents)->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')))->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString());
}
开发者ID:practico,项目名称:Cachet,代码行数:51,代码来源:StatusPageController.php
示例20: compose
/**
* Index page view composer.
*
* @param \Illuminate\Contracts\View\View $view
*
* @return void
*/
public function compose(View $view)
{
$view->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')));
$view->withAppAnalytics(Setting::get('app_analytics'));
$view->withAppAnalyticsGoSquared(Setting::get('app_analytics_gs'));
$view->withAppAnalyticsPiwikUrl(Setting::get('app_analytics_piwik_url'));
$view->withAppAnalyticsPiwikSiteId(Setting::get('app_analytics_piwik_siteid'));
$view->withAppBanner(Setting::get('app_banner'));
$view->withAppBannerStyleFullWidth(Setting::get('style_fullwidth_header'));
$view->withAppBannerType(Setting::get('app_banner_type'));
$view->withAppDomain(Setting::get('app_domain'));
$view->withAppGraphs(Setting::get('display_graphs'));
$view->withAppLocale(Setting::get('app_locale'));
$view->withAppName(Setting::get('app_name'));
$view->withAppStylesheet(Setting::get('app_stylesheet'));
$view->withAppUrl(Config::get('app.url'));
$view->withShowSupport(Setting::get('show_support'));
}
开发者ID:guduchango,项目名称:Cachet,代码行数:25,代码来源:AppComposer.php
注:本文中的CachetHQ\Cachet\Facades\Setting类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论