'', 'display_chart' => 1, 'default_value' => 0, 'calc_type' => 0, 'places' => 2, ]; /** * The validation rules. * * @var string[] */ public $rules = [ 'name' => 'required', 'suffix' => 'required', 'display_chart' => 'boolean', 'default_value' => 'numeric', 'places' => 'numeric|min:0|max:4', ]; /** * The fillable properties. * * @var string[] */ protected $fillable = [ 'name', 'suffix', 'description', 'display_chart', 'default_value', 'calc_type', 'places', ]; /** * The relations to eager load on every query. * * @var string[] */ protected $with = ['points']; /** * 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; } }