2014-11-25 11:19:20 +00:00
|
|
|
<?php
|
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
use Watson\Validating\ValidatingTrait;
|
2014-11-25 21:35:52 +00:00
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface {
|
|
|
|
use ValidatingTrait;
|
2014-11-25 21:35:52 +00:00
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
protected $rules = [
|
|
|
|
'name' => 'required',
|
|
|
|
'suffix' => 'required',
|
|
|
|
'display_chart' => 'boolean',
|
|
|
|
];
|
2014-11-25 21:35:52 +00:00
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
protected $fillable = ['name', 'suffix', 'description', 'display_chart'];
|
2014-11-25 21:35:52 +00:00
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
/**
|
|
|
|
* Determines whether a chart should be shown.
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function getShouldDisplayAttribute() {
|
|
|
|
return $this->display_chart === 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the transformer instance.
|
|
|
|
*
|
2014-11-27 19:18:01 +00:00
|
|
|
* @return MetricTransformer
|
2014-11-27 16:05:00 +00:00
|
|
|
*/
|
|
|
|
public function getTransformer() {
|
2014-11-27 19:18:01 +00:00
|
|
|
return new CachetHQ\Cachet\Transformers\MetricTransformer();
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
|
|
|
}
|