Fixes missing titles

This commit is contained in:
James Brooks
2016-01-03 12:26:27 +00:00
parent 3e15b84867
commit 5ccd601695
2 changed files with 17 additions and 7 deletions

View File

@@ -53,7 +53,7 @@ class ComponentGroup extends Model implements HasPresenter
*
* @var string[]
*/
protected $with = ['enabled_components'];
protected $with = ['enabled_components', 'enabled_components_lowest'];
/**
* A group can have many components.
@@ -75,6 +75,16 @@ class ComponentGroup extends Model implements HasPresenter
return $this->components()->enabled();
}
/**
* Return all of the enabled components ordered by status.
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function enabled_components_lowest()
{
return $this->components()->enabled()->orderBy('status', 'desc');
}
/**
* Get the presenter class.
*

View File

@@ -24,8 +24,8 @@ class ComponentGroupPresenter extends AbstractPresenter
*/
public function lowest_status()
{
if ($enabledComponents = $this->wrappedObject->enabled_components()->orderBy('status', 'desc')->first()) {
return $enabledComponents->status;
if ($component = $this->wrappedObject->enabled_components_lowest->first()) {
return $component->status;
}
}
@@ -36,8 +36,8 @@ class ComponentGroupPresenter extends AbstractPresenter
*/
public function lowest_human_status()
{
if ($enabledComponents = $this->wrappedObject->enabled_components()->orderBy('status', 'desc')->first()) {
return $enabledComponents->human_status;
if ($component = $this->wrappedObject->enabled_components_lowest->first()) {
return $component->human_status;
}
}
@@ -48,8 +48,8 @@ class ComponentGroupPresenter extends AbstractPresenter
*/
public function lowest_status_color()
{
if ($enabledComponents = $this->wrappedObject->enabled_components()->orderBy('status', 'desc')->first()) {
return $enabledComponents->status_color;
if ($component = $this->wrappedObject->enabled_components_lowest->first()) {
return $component->status_color;
}
}