34 lines
603 B
PHP
34 lines
603 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class OrgUnit extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'meta' => 'array',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
public function entity()
|
|
{
|
|
return $this->belongsTo(HoldingEntity::class, 'entity_id');
|
|
}
|
|
|
|
public function parent()
|
|
{
|
|
return $this->belongsTo(self::class, 'parent_id');
|
|
}
|
|
|
|
public function children()
|
|
{
|
|
return $this->hasMany(self::class, 'parent_id');
|
|
}
|
|
}
|