32 خطوط
765 B
PHP
32 خطوط
765 B
PHP
<?php
|
|
|
|
namespace App\Modules\Taxonomy\Domain;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class TaxonomyRelationship extends Model
|
|
{
|
|
use HasUlids;
|
|
|
|
protected $fillable = [
|
|
'organization_id', 'source_node_id', 'target_node_id', 'relationship_type', 'weight', 'metadata',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return ['weight' => 'decimal:4', 'metadata' => 'array'];
|
|
}
|
|
|
|
public function source(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TaxonomyNode::class, 'source_node_id');
|
|
}
|
|
|
|
public function target(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TaxonomyNode::class, 'target_node_id');
|
|
}
|
|
}
|