Completed
Push — master ( 5d60c7...e39782 )
by
unknown
9s
created

Sekolah::getJumlahPendaftarAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Bantenprov\Sekolah\Models\Bantenprov\Sekolah;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
class Sekolah extends Model
9
{
10
    use SoftDeletes;
11
12
    public $timestamps = true;
13
14
    protected $table = 'sekolahs';
15
    protected $fillable = [
16
        'nama',
17
        'npsn',
18
        'jenis_sekolah_id',
19
        'alamat',
20
        'logo',
21
        'foto_gedung',
22
        'province_id',
23
        'city_id',
24
        'district_id',
25
        'village_id',
26
        'no_telp',
27
        'email',
28
        'kode_zona',
29
        'user_id',
30
    ];
31
    protected $hidden = [
32
    ];
33
    protected $appends = [
34
        'label',
35
        'jumlah_pendaftar',
36
    ];
37
    protected $dates = [
38
        'deleted_at',
39
    ];
40
41
    public function getLabelAttribute()
42
    {
43
        return $this->nama;
44
    }
45
46
    public function user()
47
    {
48
        return $this->belongsTo('App\User', 'user_id');
49
    }
50
51
    public function jenis_sekolah()
52
    {
53
        return $this->belongsTo('Bantenprov\Sekolah\Models\Bantenprov\Sekolah\JenisSekolah', 'jenis_sekolah_id');
54
    }
55
56
    public function province()
57
    {
58
        return $this->belongsTo('Laravolt\Indonesia\Models\Province', 'province_id');
59
    }
60
61
    public function city()
62
    {
63
        return $this->belongsTo('Laravolt\Indonesia\Models\City', 'city_id');
64
    }
65
66
    public function district()
67
    {
68
        return $this->belongsTo('Laravolt\Indonesia\Models\District', 'district_id');
69
    }
70
71
    public function village()
72
    {
73
        return $this->belongsTo('Laravolt\Indonesia\Models\Village', 'village_id');
74
    }
75
76
    public function master_zona()
77
    {
78
        return $this->belongsTo('Bantenprov\Zona\Models\Bantenprov\Zona\MasterZona', 'kode_zona');
79
    }
80
81
    public function siswas()
82
    {
83
        return $this->hasMany('Bantenprov\Siswa\Models\Bantenprov\Siswa\Siswa', 'sekolah_id');
84
    }
85
86
    public function getJumlahPendaftarAttribute()
87
    {
88
        return $this->siswas->count();
89
    }
90
}
91