You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Malio/app/Models/TrafficLog.php

50 lines
1.1 KiB
PHTML

9 years ago
<?php
namespace App\Models;
use App\Utils\Tools;
class TrafficLog extends Model
{
protected $connection = 'default';
protected $table = 'user_traffic_log';
9 years ago
public function node()
{
$node = Node::where('id', $this->attributes['node_id'])->first();
9 years ago
if ($node == null) {
self::where('id', '=', $this->attributes['id'])->delete();
9 years ago
return null;
}
return $node;
9 years ago
}
8 years ago
9 years ago
public function user()
{
$user = User::where('id', $this->attributes['user_id'])->first();
9 years ago
if ($user == null) {
self::where('id', '=', $this->attributes['id'])->delete();
9 years ago
return null;
}
return $user;
9 years ago
}
public function totalUsed()
{
return Tools::flowAutoShow($this->attributes['u'] + $this->attributes['d']);
}
8 years ago
9 years ago
public function totalUsedRaw()
{
return number_format(($this->attributes['u'] + $this->attributes['d']) / 1024, 2, '.', '');
9 years ago
}
public function logTime()
{
return Tools::toDateTime($this->attributes['log_time']);
}
}