Cachet/app/Models/MetricPoint.php
2015-05-20 14:19:01 -05:00

67 lines
1.5 KiB
PHP

<?php
/*
* This file is part of Cachet.
*
* (c) James Brooks <james@cachethq.io>
* (c) Joseph Cohen <joseph.cohen@dinkbit.com>
* (c) Graham Campbell <graham@mineuk.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Models;
use Illuminate\Database\Eloquent\Model;
use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
/**
* @property int $id
* @property int $metric_id
* @property int $value
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*/
class MetricPoint extends Model implements HasPresenter
{
use ValidatingTrait;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = ['metric_id', 'value'];
/**
* The validation rules.
*
* @var string[]
*/
protected $rules = [
'value' => 'numeric|required',
];
/**
* A metric point belongs to a metric unit.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function metric()
{
return $this->belongsTo('CachetHQ\Cachet\Models\Metric', 'id', 'metric_id');
}
/**
* Get the presenter class.
*
* @return string
*/
public function getPresenterClass()
{
return 'CachetHQ\Cachet\Presenters\MetricPointPresenter';
}
}