return $this->restrictions->where('role_id', $role_id)->where('action', $action)->count() > 0;
}
+ /**
+ * Get the entity permissions this is connected to.
+ * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ */
+ public function permissions()
+ {
+ return $this->morphMany(EntityPermission::class, 'entity');
+ }
+
/**
* Allows checking of the exact class, Used to check entity type.
* Cleaner method for is_a.
*/
public static function isA($type)
{
- return static::getClassName() === strtolower($type);
+ return static::getType() === strtolower($type);
+ }
+
+ /**
+ * Get entity type.
+ * @return mixed
+ */
+ public static function getType()
+ {
+ return strtolower(static::getClassName());
}
/**