Nodelist import
This commit is contained in:
10
app/Models/Flag.php
Normal file
10
app/Models/Flag.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Flag extends Model
|
||||
{
|
||||
protected $fillable = ['flag'];
|
||||
}
|
21
app/Models/Node.php
Normal file
21
app/Models/Node.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Node extends Model
|
||||
{
|
||||
protected $fillable = ['zone_id','host_id','node_id'];
|
||||
|
||||
public function flags() {
|
||||
return $this->belongsToMany(Flag::class);
|
||||
}
|
||||
|
||||
public function hasFlag($relation, $model)
|
||||
{
|
||||
return (bool) $this->{$relation}()
|
||||
->wherePivot($model->getForeignKey(),$model->{$model->getKeyName()})
|
||||
->count();
|
||||
}
|
||||
}
|
10
app/Models/Zone.php
Normal file
10
app/Models/Zone.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Zone extends Model
|
||||
{
|
||||
protected $fillable = ['id'];
|
||||
}
|
Reference in New Issue
Block a user