Web frontend work
This commit is contained in:
12
app/Models/Domain.php
Normal file
12
app/Models/Domain.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\ScopeActive;
|
||||
|
||||
class Domain extends Model
|
||||
{
|
||||
use ScopeActive;
|
||||
}
|
@@ -6,18 +6,64 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Node extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'is_zc'=>'boolean',
|
||||
'is_rc'=>'boolean',
|
||||
'is_hub'=>'boolean',
|
||||
'is_host'=>'boolean',
|
||||
];
|
||||
protected $fillable = ['zone_id','host_id','node_id','point_id'];
|
||||
|
||||
public function flags() {
|
||||
/* SCOPES */
|
||||
|
||||
public function scopeHost()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
/**
|
||||
* Node nodelist flags
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function flags()
|
||||
{
|
||||
return $this->belongsToMany(Flag::class);
|
||||
}
|
||||
|
||||
public function getFTNAttribute()
|
||||
public function zone()
|
||||
{
|
||||
return sprintf('%s:%s/%s.%s',$this->zone_id,$this->host_id,$this->node_id,$this->point_id);
|
||||
return $this->belongsTo(Zone::class);
|
||||
}
|
||||
|
||||
public function hasFlag($relation, $model)
|
||||
/* ATTRIBUTES */
|
||||
|
||||
/**
|
||||
* Render the node name in full 5D
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFTNAttribute()
|
||||
{
|
||||
return $this->zone_id
|
||||
? sprintf('%s:%s/%s.%s',$this->zone->zone_id,$this->host_id,$this->node_id,$this->point_id)
|
||||
: '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this nodes uplink
|
||||
*/
|
||||
public function getUplinkAttribute()
|
||||
{
|
||||
// @todo Need to work this out properly
|
||||
return static::where('zone_id','10')->where('host_id',1)->where('node_id',0)->where('point_id',0)->first();
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
|
||||
public function hasFlag($relation,$model)
|
||||
{
|
||||
return (bool) $this->{$relation}()
|
||||
->wherePivot($model->getForeignKey(),$model->{$model->getKeyName()})
|
||||
|
9
app/Models/Protocol.php
Normal file
9
app/Models/Protocol.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Protocol extends Model
|
||||
{
|
||||
}
|
9
app/Models/Software.php
Normal file
9
app/Models/Software.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Software extends Model
|
||||
{
|
||||
}
|
@@ -10,6 +10,13 @@ class Zone extends Model
|
||||
{
|
||||
use ScopeActive;
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
public function domain()
|
||||
{
|
||||
return $this->belongsTo(Domain::class);
|
||||
}
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user