ClientCertificate::dedicatedServers()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Gameap\Models;
4
5
use Gameap\Services\Daemon\CertificateService;
6
use Illuminate\Database\Eloquent\Model;
7
8
/**
9
 * Class ClientCertificate
10
 * @package Gameap\Models
11
 *
12
 * @property int $id
13
 * @property string $fingerprint
14
 * @property string $expires
15
 * @property string $certificate
16
 * @property string $private_key
17
 * @property string $private_key_pass
18
 * @property array $info
19
 */
20
class ClientCertificate extends Model
21
{
22
    /**
23
     * @var bool
24
     */
25
    public $timestamps = false;
26
27
    /**
28
     * The attributes that are mass assignable.
29
     *
30
     * @var array
31
     */
32
    protected $fillable = [
33
        'fingerprint', 'expires', 'certificate', 'private_key', 'private_key_pass',
34
    ];
35
36
    /**
37
     * @var array
38
     */
39
    protected static $rules = [
40
        'certificate'      => 'required',
41
        'private_key'      => 'required',
42
        'private_key_pass' => '',
43
    ];
44
45
    /**
46
     * One to many relation
47
     *
48
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
49 3
     */
50
    public function dedicatedServers()
51 3
    {
52
        return $this->hasMany(DedicatedServer::class);
53
    }
54
55
    public function getInfoAttribute()
56
    {
57
        return CertificateService::certificateInfo($this->certificate);
58
    }
59
}
60