1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Modules\Machine\Entities; |
4
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
6
|
|
|
use Foundation\Contracts\Ownable; |
7
|
|
|
use Foundation\Traits\ModelFactory; |
8
|
|
|
use Foundation\Traits\Notifiable; |
9
|
|
|
use Foundation\Traits\OwnedByUser; |
10
|
|
|
use Jenssegers\Mongodb\Eloquent\SoftDeletes; |
11
|
|
|
use Modules\Account\Entities\Account; |
12
|
|
|
use Modules\Machine\Policies\MachinePolicy; |
13
|
|
|
use Modules\Mongo\Abstracts\MongoModel; |
14
|
|
|
use Modules\User\Entities\User; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class User. |
18
|
|
|
* |
19
|
|
|
* @property string $_id |
20
|
|
|
* @property string $id |
21
|
|
|
* @property string $user_id |
22
|
|
|
* @property string $alias |
23
|
|
|
* @property string $hostname |
24
|
|
|
* @property string $username |
25
|
|
|
* @property string $os |
26
|
|
|
* @property string $hash |
27
|
|
|
* @property bool $active |
28
|
|
|
* @property string $ip_address |
29
|
|
|
* @property string $mac_address |
30
|
|
|
* @property int $memory_usage |
31
|
|
|
* @property int $memory_available |
32
|
|
|
* @property int $cpu_usage |
33
|
|
|
* @property float $cpu_clock |
34
|
|
|
* @property bool $online |
35
|
|
|
* @property Carbon $last_heartbeat |
36
|
|
|
* @property Carbon $created_at |
37
|
|
|
* @property Carbon $updated_at |
38
|
|
|
* @property Carbon $deleted_at |
39
|
|
|
*/ |
40
|
|
|
class Machine extends MongoModel implements Ownable |
41
|
|
|
{ |
42
|
|
|
use Notifiable, OwnedByUser, ModelFactory, SoftDeletes; |
|
|
|
|
43
|
|
|
|
44
|
|
|
protected $policies = [ |
45
|
|
|
MachinePolicy::class, |
46
|
|
|
]; |
47
|
|
|
|
48
|
|
|
protected $observers = [ |
49
|
|
|
|
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
protected $collection = 'machines'; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var array |
59
|
|
|
*/ |
60
|
|
|
protected $guarded = []; |
61
|
|
|
|
62
|
|
|
protected $casts = [ |
63
|
|
|
'online' => 'boolean', |
64
|
|
|
'active' => 'boolean', |
65
|
|
|
]; |
66
|
|
|
|
67
|
|
|
protected $dates = [ |
68
|
|
|
'created_at', |
69
|
|
|
'updated_at', |
70
|
|
|
'deleted_at', |
71
|
|
|
'last_heartbeat', |
72
|
|
|
]; |
73
|
|
|
|
74
|
|
|
public function user() |
75
|
|
|
{ |
76
|
|
|
return $this->belongsTo(User::class); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function accounts() |
80
|
|
|
{ |
81
|
|
|
return $this->hasMany(Account::class); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|