44 lines
909 B
PHP
44 lines
909 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class HoldingEntity extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'meta' => 'array',
|
|
'is_internal' => 'boolean',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function units()
|
|
{
|
|
return $this->hasMany(OrgUnit::class, 'entity_id');
|
|
}
|
|
|
|
public function assignments()
|
|
{
|
|
return $this->hasMany(EmploymentAssignment::class, 'entity_id');
|
|
}
|
|
|
|
public function businessLocation()
|
|
{
|
|
$locationId = data_get($this->meta, 'business_location_id');
|
|
|
|
return $locationId
|
|
? BusinessLocation::where('business_id', $this->business_id)->find($locationId)
|
|
: null;
|
|
}
|
|
}
|