clrghouz/app/Models/Node.php

21 lines
404 B
PHP
Raw Normal View History

2019-04-26 04:30:00 +00:00
<?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();
}
}