/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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'))); }
/** * 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); }
/** * 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; }
/** * 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)); }
/** * 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)); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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']); }
/** * 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')); }
/** * 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()); }
/** * 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')); }
/** * Handle the report incident command. * * @param \CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand $command * * @return \CachetHQ\Cachet\Models\Incident */ public function handle(ReportIncidentCommand $command) { $incident = Incident::create(['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible, 'component' => $command->component_id]); // The incident occurred at a different time. if ($command->incident_date) { $incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone')); $incident->update(['created_at' => $incidentDate, 'updated_at' => $incidentDate]); } // Update the component. if ($command->component_id) { Component::find($command->component_id)->update(['status' => $command->component_status]); } // Notify subscribers. if ($command->notify) { event(new IncidentWasReportedEvent($incident)); } return $incident; }
/** * Handle the update incident command. * * @param \CachetHQ\Cachet\Commands\Incident\UpdateIncidentCommand $command * * @return \CachetHQ\Cachet\Models\Incident */ public function handle(UpdateIncidentCommand $command) { $incident = $command->incident; $incident->update($this->filterIncidentData($command)); // The incident occurred at a different time. if ($command->incident_date) { $incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone')); $incident->update(['created_at' => $incidentDate, 'updated_at' => $incidentDate]); } // Update the component. if ($command->component_id) { Component::find($command->component_id)->update(['status' => $command->component_status]); } // Notify subscribers. if ($command->notify) { event(new IncidentWasUpdatedEvent($incident)); } return $incident; }
/** * Create a new incident. * * @param \Illuminate\Contracts\Auth\Guard $auth * * @return \CachetHQ\Cachet\Models\Incident */ public function postIncidents(Guard $auth) { $incidentData = Binput::all(); try { $incident = Incident::create($incidentData); } catch (Exception $e) { throw new BadRequestHttpException(); } $isEnabled = (bool) Setting::get('enable_subscribers', false); $mailAddress = env('MAIL_ADDRESS', false); $mailFrom = env('MAIL_NAME', false); $subscribersEnabled = $isEnabled && $mailAddress && $mailFrom; if (array_get($incidentData, 'notify') && $subscribersEnabled) { event(new IncidentHasReportedEvent($incident)); } if ($incident->isValid()) { return $this->item($incident); } throw new BadRequestHttpException(); }
/** * Index page view composer. * * @param \Illuminate\Contracts\View\View $view */ public function compose(View $view) { // Default data $withData = ['systemStatus' => 'danger', 'systemMessage' => trans('cachet.service.bad'), 'favicon' => 'favicon-high-alert']; if (Component::notStatus(1)->count() === 0) { // If all our components are ok, do we have any non-fixed incidents? $incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get(); $incidentCount = $incidents->count(); if ($incidentCount === 0 || $incidentCount >= 1 && (int) $incidents->first()->status === 4) { $withData = ['systemStatus' => 'success', 'systemMessage' => trans('cachet.service.good'), 'favicon' => 'favicon']; } } else { if (Component::whereIn('status', [2, 3])->count() > 0) { $withData['favicon'] = 'favicon-medium-alert'; } } // 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(); $view->with($withData)->withComponentGroups($componentGroups)->withUngroupedComponents($ungroupedComponents)->withScheduledMaintenance($scheduledMaintenance)->withPageTitle(Setting::get('app_name')); }
/** * Create a new metric repository class. * * @param \CachetHQ\Cachet\Repositories\Metric\MetricInterface $repository */ public function __construct(MetricInterface $repository) { $this->repository = $repository; $this->dateTimeZone = SettingFacade::get('app_timezone'); }
/** * Show the subscribe by email page. * * @return \Illuminate\View\View */ public function showSubscribe() { return View::make('subscribe')->withAboutApp(Markdown::convertToHtml(Setting::get('app_about'))); }
/** * Edit an incident. * * @param \CachetHQ\Cachet\Models\Incident $incident * * @return \Illuminate\Http\RedirectResponse */ public function editIncidentAction(Incident $incident) { $incidentData = Binput::get('incident'); if (array_has($incidentData, 'created_at') && $incidentData['created_at']) { $incidentDate = Date::createFromFormat('d/m/Y H:i', $incidentData['created_at'], Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone')); $incidentData['created_at'] = $incidentDate; $incidentData['updated_at'] = $incidentDate; } else { unset($incidentData['created_at']); } try { $incident->update($incidentData); } catch (ValidationException $e) { return Redirect::route('dashboard.incidents.edit', ['id' => $incident->id])->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))->withErrors($e->getMessageBag()); } $componentStatus = array_pull($incidentData, 'component_status'); if ($incident->component) { $incident->component->update(['status' => $componentStatus]); } return Redirect::route('dashboard.incidents.edit', ['id' => $incident->id])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success'))); }
/** * Creates a new instance of the metric repository. * * @return void */ public function __construct() { $this->dateTimeZone = SettingFacade::get('app_timezone'); }
/** * Handles the actual app setup, including user, settings and env. * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response */ public function postStep3() { $postData = Binput::all(); $v = Validator::make($postData, $this->rulesStep1 + $this->rulesStep2 + $this->rulesStep3); if ($v->passes()) { // Pull the user details out. $userDetails = array_pull($postData, 'user'); $user = User::create(['username' => $userDetails['username'], 'email' => $userDetails['email'], 'password' => $userDetails['password'], 'level' => User::LEVEL_ADMIN]); Auth::login($user); $settings = array_pull($postData, 'settings'); foreach ($settings as $settingName => $settingValue) { Setting::set($settingName, $settingValue); } $envData = array_pull($postData, 'env'); // Write the env to the .env file. foreach ($envData as $envKey => $envValue) { $this->writeEnv($envKey, $envValue); } Session::flash('setup.done', true); if (Request::ajax()) { return Response::json(['status' => 1]); } return Redirect::to('dashboard'); } if (Request::ajax()) { return Response::json(['errors' => $v->getMessageBag()], 400); } return Redirect::route('setup.index')->withInput()->withErrors($v->getMessageBag()); }
/** * Adds an item to the feed. * * @param \Roumen\Feed\Facades\Feed $feed * @param \CachetHQ\Cachet\Models\Incident $incident */ private function feedAddItem(&$feed, $incident) { $feed->add($incident->name, Setting::get('app_name'), Str::canonicalize(Setting::get('app_domain')) . '#' . $incident->id, $incident->created_at->toRssString(), $incident->message); }