clrghouz/app/Models/Node.php
2019-04-26 14:30:00 +10:00

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();
}
}