'', 'display_chart' => 1, 'default_value' => 0, 'calc_type' => 0, 'places' => 2, 'default_view' => 1, ]; /** * The attributes that should be casted to native types. * * @var string[] */ protected $casts = [ 'id' => 'int', 'name' => 'string', 'display_chart' => 'bool', 'default_value' => 'int', 'calc_type' => 'int', 'places' => 'int', 'default_view' => 'int', ]; /** * The fillable properties. * * @var string[] */ protected $fillable = [ 'name', 'suffix', 'description', 'display_chart', 'default_value', 'calc_type', 'places', 'default_view', ]; /** * The validation rules. * * @var string[] */ public $rules = [ 'name' => 'required', 'suffix' => 'required', 'display_chart' => 'bool', 'default_value' => 'numeric', 'places' => 'numeric|between:0,4', 'default_view' => 'numeric|between:0,3', ]; /** * Metrics contain many metric points. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function points() { return $this->hasMany(MetricPoint::class, 'metric_id', 'id'); } /** * Determines whether a chart should be shown. * * @return bool */ public function getShouldDisplayAttribute() { return $this->display_chart === 1; } /** * Get the presenter class. * * @return string */ public function getPresenterClass() { return MetricPresenter::class; } }