Smarter handling of the service status

This commit is contained in:
James Brooks
2014-12-31 15:56:08 +00:00
parent 655042da3c
commit 7d8bf7fb3a
2 changed files with 39 additions and 5 deletions

View File

@@ -33,6 +33,32 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
return $this->hasMany('Incident', 'component_id', 'id');
}
/**
* Finds all components by status.
*
* @param Illuminate\Database\Eloquent\Builder $query
* @param int $status
*
* @return Illuminate\Database\Eloquent\Builder
*/
public function scopeStatus($query, $status)
{
return $query->where('status', $status);
}
/**
* Finds all components which don't have the given status.
*
* @param Illuminate\Database\Eloquent\Builder $query
* @param int $status
*
* @return Illuminate\Database\Eloquent\Builder
*/
public function scopeNotStatus($query, $status)
{
return $query->where('status', '<>', $status);
}
/**
* Looks up the human readable version of the status.
*