Create and update a metric.

This commit is contained in:
James Brooks
2014-11-25 21:35:52 +00:00
parent f71639f226
commit 39bc6a1648
4 changed files with 88 additions and 1 deletions
+28 -1
View File
@@ -1,5 +1,32 @@
<?php
class Metric extends Eloquent {
use \Watson\Validating\ValidatingTrait;
class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface {
use ValidatingTrait;
protected $rules = [
'name' => 'required',
'suffix' => 'required',
'display_chart' => 'boolean',
];
protected $fillable = ['name', 'suffix', 'description', 'display_chart'];
/**
* Determines whether a chart should be shown.
* @return bool
*/
public function getShouldDisplayAttribute() {
return $this->display_chart === 1;
}
/**
* Get the transformer instance.
*
* @return ComponentTransformer
*/
public function getTransformer() {
return new MetricTransformer();
}
}