Ruangrawat::boot()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 9.4285
1
<?php namespace Bantenprov\YankesInfoKamar\Models;
2
3
use Illuminate\Database\Eloquent\Model;
4
use Illuminate\Database\Eloquent\SoftDeletes;
5
6
/**
7
 * The InfoKamarModel class.
8
 *
9
 * @package Supriyanih\InfoKamar
10
 * @author  supriyanih <[email protected]>
11
 */
12
class Ruangrawat extends Model
13
{
14
    /**
15
    * Table name.
16
    *
17
    * @var string
18
    */
19
      use SoftDeletes;
20
    protected $table = 'ruang_rawat_inap';
21
22
    /**
23
    * The attributes that are mass assignable.
24
    *
25
    * @var mixed
26
    */
27
    protected $fillable = ['kelas_id','kode_ruang','nama_ruang'];
28
29
    /**
30
     * The attributes that should be hidden for arrays.
31
     *
32
     * @var array
33
     */
34
    protected $hidden = ['deleted_at'];
35
36
    protected static function boot()
37
        {
38
          parent::boot();
39
40
          static::deleting(function($ruang_rawat_inap) {
41
             foreach ($ruang_rawat_inap->ranjang()->get() as $bed) {
42
                $bed->delete();
43
             }
44
          });
45
        }
46
47
    public function kelas()
48
     {
49
        return  $this->belongsTo('Bantenprov\YankesInfoKamar\Models\Kelasrawat','kelas_id');
50
     }
51
52
53
     public function ranjang()
54
    {
55
      return  $this->hasMany('Bantenprov\YankesInfoKamar\Models\Tempattidur','ruang_id');
56
    }
57
}
58