make(PermissionApplicator::class)->restrictEntityQuery($query); } /** * Get the entity jointPermissions this is connected to. */ public function jointPermissions(): HasMany { return $this->hasMany(JointPermission::class, 'entity_id') ->whereColumn('entity_type', '=', 'entities.type'); } /** * Get the Tags that have been assigned to entities. */ public function tags(): HasMany { return $this->hasMany(Tag::class, 'entity_id') ->whereColumn('entity_type', '=', 'entities.type'); } /** * Get the assigned permissions. */ public function permissions(): HasMany { return $this->hasMany(EntityPermission::class, 'entity_id') ->whereColumn('entity_type', '=', 'entities.type'); } /** * Get View objects for this entity. */ public function views(): HasMany { return $this->hasMany(View::class, 'viewable_id') ->whereColumn('viewable_type', '=', 'entities.type'); } }