Machine::accounts()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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;
0 ignored issues
show
introduced by
The trait Foundation\Traits\Notifiable requires some properties which are not provided by Modules\Machine\Entities\Machine: $email, $phone_number
Loading history...
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