Added laravel/passport, assign ftn addresses to nodes
This commit is contained in:
52
app/Models/Address.php
Normal file
52
app/Models/Address.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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 '?';
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user