38 lines
841 B
PHP
38 lines
841 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class InstanceTraffic extends Model
|
|
{
|
|
protected $table = 'instance_traffic';
|
|
|
|
protected $guarded = [];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'rx_bytes' => 'integer',
|
|
'tx_bytes' => 'integer',
|
|
'last_netin' => 'integer',
|
|
'last_netout' => 'integer',
|
|
'notified_percent' => 'integer',
|
|
'throttled' => 'boolean',
|
|
'sampled_at' => 'datetime',
|
|
'throttled_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function instance(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Instance::class);
|
|
}
|
|
|
|
public static function currentPeriod(): string
|
|
{
|
|
return now()->format('Y-m');
|
|
}
|
|
}
|