Sktm::user()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Bantenprov\Sktm\Models\Bantenprov\Sktm;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
class Sktm extends Model
9
{
10
    use SoftDeletes;
11
12
    public $timestamps = true;
13
14
    protected $table = 'sktms';
15
    protected $fillable = [
16
        'nomor_un',
17
        'master_sktm_id',
18
        'no_sktm',
19
        'nilai',
20
        'user_id',
21
    ];
22
    protected $hidden = [
23
    ];
24
    protected $appends = [
25
        'label',
26
    ];
27
    protected $dates = [
28
        'deleted_at',
29
    ];
30
31
    public function getLabelAttribute()
32
    {
33
        if ($this->siswa !== null) {
34
            return $this->siswa->nomor_un.' - '.$this->siswa->nama_siswa;
35
        } else {
36
            return $this->nomor_un.' - ';
37
        }
38
    }
39
40
    public function siswa()
41
    {
42
        return $this->belongsTo('Bantenprov\Siswa\Models\Bantenprov\Siswa\Siswa', 'nomor_un', 'nomor_un');
43
    }
44
45
    public function master_sktm()
46
    {
47
        return $this->belongsTo('Bantenprov\Sktm\Models\Bantenprov\Sktm\MasterSktm', 'master_sktm_id');
48
    }
49
50
    public function user()
51
    {
52
        return $this->belongsTo('App\User', 'user_id');
53
    }
54
}
55