Custom Backend OSPRO Surveyor Indonesia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
734 B

11 months ago
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Divisi extends Model
{
protected $table = 'm_divisi';
11 months ago
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
11 months ago
protected $fillable = [
'name',
11 months ago
'parent',
'description',
'color',
'created_at',
'created_by',
'updated_at',
'updated_by',
'company_id'
];
public static function boot()
{
11 months ago
parent::boot();
static::deleting(function ($data) {
11 months ago
$data->children()->delete();
});
}
public function parent()
{
return $this->belongsTo('App\Models\Divisi', 'parent')->where('parent', null)->with('parent');
11 months ago
}
public function children()
{
return $this->hasMany('App\Models\Divisi', 'parent')->with('children');
11 months ago
}
}