本文整理汇总了PHP中CachetHQ\Cachet\Models\Component类的典型用法代码示例。如果您正苦于以下问题:PHP Component类的具体用法?PHP Component怎么用?PHP Component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Component类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the report incident command.
*
* @param \CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand $command
*
* @return \CachetHQ\Cachet\Models\Incident
*/
public function handle(ReportIncidentCommand $command)
{
if ($command->template) {
$command->message = $this->parseIncidentTemplate($command->template, $command->template_vars);
}
$data = ['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible];
// Link with the component.
if ($command->component_id) {
$data['component_id'] = $command->component_id;
}
// The incident occurred at a different time.
if ($command->incident_date) {
$incidentDate = $this->dates->createNormalized('d/m/Y H:i', $command->incident_date);
$data['created_at'] = $incidentDate;
$data['updated_at'] = $incidentDate;
}
// Create the incident
$incident = Incident::create($data);
// Update the component.
if ($command->component_id) {
Component::find($command->component_id)->update(['status' => $command->component_status]);
}
$incident->notify = (bool) $command->notify;
event(new IncidentWasReportedEvent($incident));
return $incident;
}
开发者ID:minhkiller,项目名称:Cachet,代码行数:33,代码来源:ReportIncidentCommandHandler.php
示例2: handle
/**
* Handle the report incident command.
*
* @param \CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand $command
*
* @return \CachetHQ\Cachet\Models\Incident
*/
public function handle(ReportIncidentCommand $command)
{
$data = ['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible];
// Link with the component.
if ($command->component_id) {
$data['component_id'] = $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, config('cachet.timezone'))->setTimezone(Config::get('app.timezone'));
$data['created_at'] = $incidentDate;
$data['updated_at'] = $incidentDate;
}
// Create the incident
$incident = Incident::create($data);
// 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;
}
开发者ID:ryanwinchester-forks,项目名称:Cachet,代码行数:32,代码来源:ReportIncidentCommandHandler.php
示例3: showDashboard
/**
* Shows the dashboard view.
*
* @return \Illuminate\View\View
*/
public function showDashboard()
{
$components = Component::orderBy('order')->get();
$incidents = $this->getIncidents();
$subscribers = $this->getSubscribers();
return View::make('dashboard.index')->withComponents($components)->withIncidents($incidents)->withSubscribers($subscribers);
}
开发者ID:practico,项目名称:Cachet,代码行数:12,代码来源:DashboardController.php
示例4: compose
/**
* Bind data to the view.
*
* @param \Illuminate\Contracts\View\View $view
*
* @return void
*/
public function compose(View $view)
{
$view->withIncidentCount(Incident::notScheduled()->count());
$view->withIncidentTemplateCount(IncidentTemplate::count());
$view->withComponentCount(Component::all()->count());
$view->withSubscriberCount(Subscriber::isVerified()->count());
}
开发者ID:aksalj,项目名称:Cachet,代码行数:14,代码来源:DashboardComposer.php
示例5: compose
/**
* Index page view composer.
*
* @param \Illuminate\Contracts\View\View $view
*
* @return void
*/
public function compose(View $view)
{
$totalComponents = Component::enabled()->count();
$majorOutages = Component::enabled()->status(4)->count();
$isMajorOutage = $majorOutages / $totalComponents >= 0.5;
// Default data
$withData = ['system_status' => 'info', 'system_message' => trans_choice('cachet.service.bad', $totalComponents), 'favicon' => 'favicon-high-alert'];
if ($isMajorOutage) {
$withData = ['system_status' => 'danger', 'system_message' => trans_choice('cachet.service.major', $totalComponents), 'favicon' => 'favicon-high-alert'];
} elseif (Component::enabled()->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 = ['system_status' => 'success', 'system_message' => trans_choice('cachet.service.good', $totalComponents), 'favicon' => 'favicon'];
}
} else {
if (Component::enabled()->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::enabled()->where('group_id', '>', 0)->groupBy('group_id')->pluck('group_id');
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
$ungroupedComponents = Component::enabled()->where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
$view->with($withData)->withComponentGroups($componentGroups)->withUngroupedComponents($ungroupedComponents)->withScheduledMaintenance($scheduledMaintenance);
}
开发者ID:bashou,项目名称:Cachet,代码行数:36,代码来源:StatusPageComposer.php
示例6: putComponent
/**
* Update an existing component.
*
* @param \CachetHQ\Cachet\Models\Component $component
*
* @return \Illuminate\Http\JsonResponse
*/
public function putComponent(Component $component)
{
try {
$component->update(Binput::except('tags'));
} catch (Exception $e) {
throw new BadRequestHttpException();
}
if (Binput::has('tags')) {
$tags = preg_split('/ ?, ?/', Binput::get('tags'));
// For every tag, do we need to create it?
$componentTags = array_map(function ($taggable) use($component) {
return Tag::firstOrCreate(['name' => $taggable])->id;
}, $tags);
$component->tags()->sync($componentTags);
}
return $this->item($component);
}
开发者ID:practico,项目名称:Cachet,代码行数:24,代码来源:ComponentController.php
示例7: seedComponents
/**
* Seed the components table.
*
* @return void
*/
protected function seedComponents()
{
$defaultComponents = [['name' => 'API', 'description' => 'Used by third-parties to connect to us', 'status' => 1, 'order' => 0, 'group_id' => 0, 'link' => ''], ['name' => 'Documentation', 'description' => 'Kindly powered by Readme.io', 'status' => 1, 'order' => 0, 'group_id' => 0, 'link' => 'https://docs.cachethq.io'], ['name' => 'Website', 'description' => '', 'status' => 1, 'order' => 0, 'group_id' => 0, 'link' => 'https://cachethq.io'], ['name' => 'Blog', 'description' => 'The Cachet Blog.', 'status' => 1, 'order' => 0, 'group_id' => 0, 'link' => 'https://blog.cachethq.io']];
Component::truncate();
foreach ($defaultComponents as $component) {
Component::create($component);
}
}
开发者ID:seanherron,项目名称:Cachet,代码行数:13,代码来源:DemoSeederCommand.php
示例8: handle
/**
* Handle the add component command.
*
* @param \CachetHQ\Cachet\Commands\Component\AddComponentCommand $command
*
* @return \CachetHQ\Cachet\Models\Component
*/
public function handle(AddComponentCommand $command)
{
$componentData = array_filter(['name' => $command->name, 'description' => $command->description, 'link' => $command->link, 'status' => $command->status, 'order' => $command->order, 'group_id' => $command->group_id]);
$componentData['enabled'] = $command->enabled;
$component = Component::create($componentData);
event(new ComponentWasAddedEvent($component));
return $component;
}
开发者ID:rafix82,项目名称:Cachet,代码行数:15,代码来源:AddComponentCommandHandler.php
示例9: run
/**
* Run the database seeding.
*
* @return void
*/
public function run()
{
Model::unguard();
$defaultComponents = [["name" => "API", "description" => "Used by third-parties to connect to us", "status" => 1, "user_id" => 1], ["name" => "Payments", "description" => "Backed by Stripe", "status" => 1, "user_id" => 1], ["name" => "Website", "status" => 1, "user_id" => 1]];
Component::truncate();
foreach ($defaultComponents as $component) {
Component::create($component);
}
}
开发者ID:baa-archieve,项目名称:Cachet,代码行数:14,代码来源:ComponentTableSeeder.php
示例10: updateComponentAction
/**
* Updates a component.
*
* @param \CachetHQ\Cachet\Models\Component $component
*
* @return \Illuminate\Http\RedirectResponse
*/
public function updateComponentAction(Component $component)
{
$_component = Binput::get('component');
$tags = array_pull($_component, 'tags');
try {
$component->update($_component);
} catch (ValidationException $e) {
return Redirect::route('dashboard.components.edit', ['id' => $component->id])->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))->withErrors($e->getMessageBag());
}
// The component was added successfully, so now let's deal with the tags.
$tags = preg_split('/ ?, ?/', $tags);
// For every tag, do we need to create it?
$componentTags = array_map(function ($taggable) use($component) {
return Tag::firstOrCreate(['name' => $taggable])->id;
}, $tags);
$component->tags()->sync($componentTags);
return Redirect::route('dashboard.components.edit', ['id' => $component->id])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success')));
}
开发者ID:practico,项目名称:Cachet,代码行数:25,代码来源:ComponentController.php
示例11: postUpdateComponentOrder
/**
* Updates a components ordering.
*
* @return array
*/
public function postUpdateComponentOrder()
{
$componentData = Binput::get('ids');
foreach ($componentData as $order => $componentId) {
// Ordering should be 1-based, data comes in 0-based
Component::find($componentId)->update(['order' => $order + 1]);
}
return $componentData;
}
开发者ID:kulado,项目名称:Cachet,代码行数:14,代码来源:ApiController.php
示例12: postUpdateComponentOrder
/**
* Updates a components ordering.
*
* @return array
*/
public function postUpdateComponentOrder()
{
$componentData = Binput::all();
unset($componentData['component'][0]);
// Remove random 0 index.
foreach ($componentData['component'] as $componentId => $order) {
$component = Component::find($componentId);
$component->update(['order' => $order]);
}
return $componentData;
}
开发者ID:baa-archieve,项目名称:Cachet,代码行数:16,代码来源:DashAPIController.php
示例13: showIndex
/**
* Returns the rendered Blade templates.
*
* @return \Illuminate\View\View
*/
public function showIndex()
{
$components = Component::orderBy('order')->orderBy('created_at')->get();
$allIncidents = [];
$incidentDays = Setting::get('app_incident_days') ?: 7;
foreach (range(0, $incidentDays) as $i) {
$date = Carbon::now()->subDays($i);
$incidents = Incident::whereBetween('created_at', [$date->format('Y-m-d') . ' 00:00:00', $date->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get();
$allIncidents[] = ['date' => $date->format('jS F Y'), 'incidents' => $incidents];
}
return View::make('index', ['components' => $components, 'allIncidents' => $allIncidents, 'pageTitle' => Setting::get('app_name'), 'aboutApp' => Markdown::render(Setting::get('app_about'))]);
}
开发者ID:baa-archieve,项目名称:Cachet,代码行数:17,代码来源:HomeController.php
示例14: getComponentStatus
/**
* Find the status on a component.
*
* @param string $componentId
*
* @return string
*/
protected function getComponentStatus($componentId = '')
{
if ('' == $componentId) {
return 'n/a';
}
$statuses = trans('cachet.components.status');
$component = Component::find($componentId);
if ($component instanceof Component) {
return $component->name . ': *' . $statuses[$component->status] . '*';
}
return 'n/a';
}
开发者ID:mrbase,项目名称:cachet-slack-integration,代码行数:19,代码来源:BaseHandler.php
示例15: postUpdateComponentOrder
/**
* Updates a components ordering.
*
* @return array
*/
public function postUpdateComponentOrder()
{
$componentData = Binput::get('ids');
foreach ($componentData as $order => $componentId) {
try {
$component = Component::find($componentId);
dispatch(new UpdateComponentCommand($component, $component->name, $component->description, $component->status, $component->link, $order + 1, $component->group_id, $component->enabled));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
}
return $this->collection(Component::query()->orderBy('order')->get());
}
开发者ID:aksalj,项目名称:Cachet,代码行数:18,代码来源:ApiController.php
示例16: handle
/**
* 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]);
// 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;
}
开发者ID:practico,项目名称:Cachet,代码行数:20,代码来源:ReportIncidentCommandHandler.php
示例17: showDashboard
/**
* Shows the dashboard view.
*
* @return \Illuminate\View\View
*/
public function showDashboard()
{
$components = Component::orderBy('order')->get();
$incidents = $this->getIncidents();
$subscribers = $this->getSubscribers();
$usedComponentGroups = Component::enabled()->where('group_id', '>', 0)->groupBy('group_id')->pluck('group_id');
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
$ungroupedComponents = Component::enabled()->where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
$entries = null;
if ($feed = $this->feed->latest()) {
$entries = array_slice($feed->channel->item, 0, 5);
}
return View::make('dashboard.index')->withPageTitle(trans('dashboard.dashboard'))->withComponents($components)->withIncidents($incidents)->withSubscribers($subscribers)->withEntries($entries)->withComponentGroups($componentGroups)->withUngroupedComponents($ungroupedComponents);
}
开发者ID:aksalj,项目名称:Cachet,代码行数:19,代码来源:DashboardController.php
示例18: compose
/**
* 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')];
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')];
}
}
$view->with($withData);
}
开发者ID:2bj,项目名称:Cachet,代码行数:19,代码来源:IndexComposer.php
示例19: 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
示例20: handle
/**
* 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 = $this->dates->createNormalized('d/m/Y H:i', $command->incident_date);
$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]);
}
event(new IncidentWasUpdatedEvent($incident));
return $incident;
}
开发者ID:rafix82,项目名称:Cachet,代码行数:23,代码来源:UpdateIncidentCommandHandler.php
注:本文中的CachetHQ\Cachet\Models\Component类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论