attributes->has($attribute); } /** * Get the error field name. * If the parent class has an error field name (passed via props or defined), it will be returned. * Otherwise, the model name will be returned. */ public function errorFieldName(): ?string { return $this->errorField ?? $this->modelName(); } /** * This function will return the model name from the wire:model attribute. * This is useful as we use this to bind wire:model props passed from high level * components (ex: input) to the internal html components (ex: input tag). */ public function modelName(): ?string { return $this->attributes->whereStartsWith('wire:model')->first(); } /** * Check if the input is required. */ public function isRequired(): bool { return $this->attributes->has('required') && true === $this->attributes->get('required'); } /** * Check if the input is disabled. */ public function isDisabled(): bool { return $this->attributes->has('disabled') && true === $this->attributes->get('disabled'); } /** * Check if the input is readonly. */ public function isReadonly(): bool { return $this->attributes->has('readonly') && true === $this->attributes->get('readonly'); } /** * Check if the input is autofocus. */ public function isAutofocus(): bool { return $this->attributes->has('autofocus') && true === $this->attributes->get('autofocus'); } }