Add scopes for components

This commit is contained in:
Antoine Augusti
2015-11-04 14:54:43 +01:00
parent 87bcd0c87b
commit b414a4e391
3 changed files with 30 additions and 6 deletions

View File

@@ -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.
*