mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-03-14 20:39:44 +01:00
Add scopes for components
This commit is contained in:
parent
87bcd0c87b
commit
b414a4e391
@ -35,7 +35,7 @@ class StatusPageComposer
|
||||
'favicon' => 'favicon-high-alert',
|
||||
];
|
||||
|
||||
if (Component::where('enabled', true)->notStatus(1)->count() === 0) {
|
||||
if (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();
|
||||
@ -48,7 +48,7 @@ class StatusPageComposer
|
||||
];
|
||||
}
|
||||
} else {
|
||||
if (Component::where('enabled', true)->whereIn('status', [2, 3])->count() > 0) {
|
||||
if (Component::enabled()->whereIn('status', [2, 3])->count() > 0) {
|
||||
$withData['favicon'] = 'favicon-medium-alert';
|
||||
}
|
||||
}
|
||||
@ -57,9 +57,9 @@ class StatusPageComposer
|
||||
$scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
|
||||
|
||||
// Component & Component Group lists.
|
||||
$usedComponentGroups = Component::where('enabled', true)->where('group_id', '>', 0)->groupBy('group_id')->lists('group_id');
|
||||
$usedComponentGroups = Component::enabled()->where('group_id', '>', 0)->groupBy('group_id')->lists('group_id');
|
||||
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
|
||||
$ungroupedComponents = Component::where('enabled', true)->where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
|
||||
$ungroupedComponents = Component::enabled()->where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
|
||||
|
||||
$view->with($withData)
|
||||
->withComponentGroups($componentGroups)
|
||||
|
@ -133,6 +133,30 @@ class Component extends Model implements HasPresenter
|
||||
return $query->where('status', '<>', $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all components which are enabled.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeEnabled(Builder $query)
|
||||
{
|
||||
return $query->where('enabled', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all components which are disabled.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeDisabled(Builder $query)
|
||||
{
|
||||
return $query->where('enabled', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up the human readable version of the status.
|
||||
*
|
||||
|
@ -1,14 +1,14 @@
|
||||
<ul class="list-group components">
|
||||
@if($component_groups->count() > 0)
|
||||
@foreach($component_groups as $componentGroup)
|
||||
@if($componentGroup->components->where('enabled', true)->count() > 0)
|
||||
@if($componentGroup->components->enabled()->count() > 0)
|
||||
<li class="list-group-item group-name">
|
||||
<i class="ion-ios-minus-outline group-toggle"></i>
|
||||
<strong>{{ $componentGroup->name }}</strong>
|
||||
</li>
|
||||
|
||||
<div class="group-items">
|
||||
@foreach($componentGroup->components->where('enabled', true)->sortBy('order') as $component)
|
||||
@foreach($componentGroup->components->enabled()->sortBy('order') as $component)
|
||||
@include('partials.component', compact($component))
|
||||
@endforeach
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user