21 lines
404 B
PHP
21 lines
404 B
PHP
|
<?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();
|
||
|
}
|
||
|
}
|