Giant Update
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class TopologyNode extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'latitude' => 'decimal:7',
|
||||
'longitude' => 'decimal:7',
|
||||
'installed_at' => 'date',
|
||||
'metadata' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function tenant()
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
public function deviceType()
|
||||
{
|
||||
return $this->belongsTo(TopologyDeviceType::class, 'device_type_id');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_node_id');
|
||||
}
|
||||
|
||||
public function ports()
|
||||
{
|
||||
return $this->hasMany(TopologyPort::class, 'node_id')->orderBy('port_number');
|
||||
}
|
||||
|
||||
public function outgoingLinks()
|
||||
{
|
||||
return $this->hasMany(TopologyLink::class, 'source_node_id');
|
||||
}
|
||||
|
||||
public function incomingLinks()
|
||||
{
|
||||
return $this->hasMany(TopologyLink::class, 'target_node_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user