2014-11-25 11:19:20 +00:00
|
|
|
<?php
|
|
|
|
|
2015-04-19 08:52:39 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Cachet.
|
|
|
|
*
|
|
|
|
* (c) James Brooks <james@cachethq.io>
|
2015-05-25 17:53:06 +01:00
|
|
|
* (c) Joseph Cohen <joe@cachethq.io>
|
2015-05-23 14:48:33 +01:00
|
|
|
* (c) Graham Campbell <graham@cachethq.io>
|
2015-04-19 08:52:39 +01:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2015-01-02 00:18:19 +00:00
|
|
|
namespace CachetHQ\Cachet\Models;
|
|
|
|
|
2015-01-01 12:23:17 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2015-05-16 13:57:32 -05:00
|
|
|
use McCool\LaravelAutoPresenter\HasPresenter;
|
2015-01-21 02:32:18 -06:00
|
|
|
use Watson\Validating\ValidatingTrait;
|
2015-01-01 12:23:17 +00:00
|
|
|
|
2015-01-02 12:02:04 +00:00
|
|
|
/**
|
2015-01-02 12:16:28 +00:00
|
|
|
* @property int $id
|
|
|
|
* @property int $metric_id
|
|
|
|
* @property int $value
|
|
|
|
* @property \Carbon\Carbon $created_at
|
|
|
|
* @property \Carbon\Carbon $updated_at
|
2015-01-02 12:02:04 +00:00
|
|
|
*/
|
2015-05-16 13:57:32 -05:00
|
|
|
class MetricPoint extends Model implements HasPresenter
|
2014-12-20 21:20:17 +00:00
|
|
|
{
|
2015-01-21 02:32:18 -06:00
|
|
|
use ValidatingTrait;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
2015-02-23 08:27:43 +00:00
|
|
|
* @var string[]
|
2015-01-21 02:32:18 -06:00
|
|
|
*/
|
|
|
|
protected $fillable = ['metric_id', 'value'];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The validation rules.
|
|
|
|
*
|
|
|
|
* @var string[]
|
|
|
|
*/
|
|
|
|
protected $rules = [
|
2015-03-12 18:49:45 -06:00
|
|
|
'value' => 'numeric|required',
|
2015-01-21 02:32:18 -06:00
|
|
|
];
|
|
|
|
|
2014-12-01 08:53:32 +00:00
|
|
|
/**
|
|
|
|
* A metric point belongs to a metric unit.
|
2014-12-30 18:19:22 +00:00
|
|
|
*
|
2014-12-01 08:53:32 +00:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function metric()
|
|
|
|
{
|
2015-01-02 00:18:19 +00:00
|
|
|
return $this->belongsTo('CachetHQ\Cachet\Models\Metric', 'id', 'metric_id');
|
2014-12-01 08:53:32 +00:00
|
|
|
}
|
2015-05-16 13:57:32 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the presenter class.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getPresenterClass()
|
|
|
|
{
|
|
|
|
return 'CachetHQ\Cachet\Presenters\MetricPointPresenter';
|
|
|
|
}
|
2014-11-27 22:08:28 +00:00
|
|
|
}
|