set_oc_schema($this->tagValuesOld()); } public function __get(string $key): mixed { return match ($key) { 'structural' => $this->oc_schema->filter(fn($item)=>$item->isStructural()), default => parent::__get($key), }; } public function __set(string $key,mixed $values): void { switch ($key) { case 'values': parent::__set($key,$values); // We need to populate oc_schema, if we are a new OC and thus dont have any old values if (! $this->values_old->count() && $this->values->count()) $this->set_oc_schema($this->tagValues()); break; default: parent::__set($key,$values); } } /** * Is a specific value the structural objectclass * * @param string $value * @return bool */ public function isStructural(string $value): bool { return $this->structural ->map(fn($item)=>$item->name) ->contains($value); } public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View { return view('components.attribute.objectclass') ->with('o',$this) ->with('edit',$edit) ->with('old',$old) ->with('new',$new); } private function set_oc_schema(Collection $tv): void { $this->oc_schema = config('server') ->schema('objectclasses') ->filter(fn($item)=>$tv->contains($item->name)); } }