53 lines
940 B
PHP
53 lines
940 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use App\Http\Controllers\DomainController;
|
|
|
|
class Address extends Model
|
|
{
|
|
/* RELATIONS */
|
|
|
|
public function system()
|
|
{
|
|
return $this->belongsTo(System::class);
|
|
}
|
|
|
|
public function zone()
|
|
{
|
|
return $this->belongsTo(Zone::class);
|
|
}
|
|
|
|
/* ATTRIBUTES */
|
|
|
|
/**
|
|
* Render the node name in full 5D
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getFTNAttribute()
|
|
{
|
|
return sprintf('%d:%d/%d.%d@%s',$this->zone->zone_id,$this->host_id ?: $this->region_id,$this->node_id,$this->point_id,$this->zone->domain->name);
|
|
}
|
|
|
|
public function getRoleAttribute($value)
|
|
{
|
|
switch ($value) {
|
|
case DomainController::NODE_ZC;
|
|
return 'Zone';
|
|
case DomainController::NODE_RC;
|
|
return 'Region';
|
|
case DomainController::NODE_NC;
|
|
return 'Host';
|
|
case DomainController::NODE_HC;
|
|
return 'Hub';
|
|
case NULL:
|
|
return 'Node';
|
|
default:
|
|
return '?';
|
|
}
|
|
}
|
|
}
|