Completed
Push — master ( aa41f3...565443 )
by
unknown
10s
created

Sktm::getLabelAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 8
rs 9.4285
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