mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-02-24 11:43:33 +01:00
41 lines
936 B
PHP
41 lines
936 B
PHP
<?php
|
|
|
|
use Watson\Validating\ValidatingTrait;
|
|
|
|
class Component extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface {
|
|
use ValidatingTrait;
|
|
|
|
protected $rules = [
|
|
'user_id' => 'required|integer',
|
|
'name' => 'required',
|
|
'status' => 'required|integer'
|
|
];
|
|
|
|
protected $fillable = ['name', 'description', 'status'];
|
|
|
|
/**
|
|
* Lookup all of the incidents reported on the component.
|
|
* @return Illuminate\Database\Eloquent\Relations
|
|
*/
|
|
public function incidents() {
|
|
return $this->hasMany('Incident', 'component', 'id');
|
|
}
|
|
|
|
/**
|
|
* Looks up the human readable version of the status.
|
|
* @return string
|
|
*/
|
|
public function getHumanStatusAttribute() {
|
|
return Lang::get('component.status.' . $this->status);
|
|
}
|
|
|
|
/**
|
|
* Get the transformer instance.
|
|
*
|
|
* @return ComponentTransformer
|
|
*/
|
|
public function getTransformer() {
|
|
return new ComponentTransformer();
|
|
}
|
|
}
|