. * * @package LibreNMS * @link http://librenms.org * @copyright 2018 Tony Murray * @author Tony Murray */ namespace App\Models; use Illuminate\Database\Eloquent\Model; class DevicePerf extends BaseModel { protected $table = 'device_perf'; protected $fillable = ['device_id', 'timestamp', 'xmt', 'rcv', 'loss', 'min', 'max', 'avg']; protected $casts = [ 'xmt' => 'integer', 'rcv' => 'integer', 'loss' => 'integer', 'min' => 'float', 'max' => 'float', 'avg' => 'float', ]; public $timestamps = false; const CREATED_AT = 'timestamp'; protected $attributes = [ 'min' => 0, 'max' => 0, 'avg' => 0, ]; protected static function boot() { parent::boot(); static::creating(function ($model) { $model->timestamp = $model->freshTimestamp(); }); } // ---- Define Relationships ---- public function device() { return $this->belongsTo('App\Models\Device', 'device_id', 'device_id'); } }