| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\App\Models;
- use ModulesGarden\ProxmoxAddon\Core\Models\ExtendedEloquentModel;
- /**
- * Class RrdData
- * @package ModulesGarden\ProxmoxAddon\App\Models
- * @method static $this ofHostingId($hostingId)
- * @method sinceDayAgo()
- */
- class RrdData extends ExtendedEloquentModel
- {
- /** @var string */
- protected $table = 'RrdData';
- protected $fillable = [ 'hosting_id', 'vm_id', 'diskread', 'diskwrite','cpu','maxcpu','mem','maxmem','netin','netout','time'
- ];
- public $timestamps = false;
- public function scopeOfHostingId($query, $hostingId)
- {
- return $query->where("hosting_id", $hostingId);
- }
- public function scopeSinceDayAgo($query)
- {
- $now = new \DateTime();
- $now->modify('-24 hours');
- return $query->where("time", ">=",$now->format("Y-m-d H:i:s"));
- }
- public function scopeSinceHourAgo($query)
- {
- $now = new \DateTime();
- $now->modify('-1 hours');
- return $query->where("time", ">=",$now->format("Y-m-d H:i:s"));
- }
- public function scopeOlderThanDayAgo($query)
- {
- $now = new \DateTime();
- $now->modify('-24 hours');
- return $query->where("time", "<=",$now->format("Y-m-d H:i:s"));
- }
- }
|