2014-11-16 23:01:12 +00:00
|
|
|
<?php
|
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
use Watson\Validating\ValidatingTrait;
|
|
|
|
|
|
|
|
class Component extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface {
|
|
|
|
use ValidatingTrait;
|
2014-12-13 13:50:51 +00:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
2014-11-27 16:05:00 +00:00
|
|
|
|
|
|
|
protected $rules = [
|
2014-12-13 12:43:11 +00:00
|
|
|
'user_id' => 'integer|required',
|
2014-11-27 16:05:00 +00:00
|
|
|
'name' => 'required',
|
2014-12-13 12:43:11 +00:00
|
|
|
'status' => 'integer'
|
2014-11-27 16:05:00 +00:00
|
|
|
];
|
|
|
|
|
2014-12-13 12:43:11 +00:00
|
|
|
protected $fillable = ['name', 'description', 'status', 'user_id'];
|
2014-11-27 16:05:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup all of the incidents reported on the component.
|
|
|
|
* @return Illuminate\Database\Eloquent\Relations
|
|
|
|
*/
|
|
|
|
public function incidents() {
|
2014-12-01 13:00:32 +00:00
|
|
|
return $this->hasMany('Incident', 'component_id', 'id');
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Looks up the human readable version of the status.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getHumanStatusAttribute() {
|
2014-12-01 16:37:37 +00:00
|
|
|
return Lang::get('cachet.component.status.' . $this->status);
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the transformer instance.
|
|
|
|
*
|
|
|
|
* @return ComponentTransformer
|
|
|
|
*/
|
|
|
|
public function getTransformer() {
|
2014-11-27 19:18:01 +00:00
|
|
|
return new CachetHQ\Cachet\Transformers\ComponentTransformer();
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
2014-11-27 22:08:28 +00:00
|
|
|
}
|