Property type not supported in Livewire when using computedProperties

I tried to create a resource for some third party model (Spatie\UptimeMonitor\Models\Monitor). This model uses the following method:
public function getUrlAttribute(): ?Url
{
if (! isset($this->attributes['url'])) {
return null;
}

return Url::fromString($this->attributes['url']);
}
public function getUrlAttribute(): ?Url
{
if (! isset($this->attributes['url'])) {
return null;
}

return Url::fromString($this->attributes['url']);
}
On edit page, I get now an exception Property type not supported in Livewire for property: [{}] The weird thing is, that i get this exception, even if I dont use the url property at all in the form:
public static function form(Form $form): Form
{
return $form
->schema([]);
}
public static function form(Form $form): Form
{
return $form
->schema([]);
}
When commenting the getUrlAttribute out from the package, the error isn't thrown. Any ideas how to get around this error, without messing up the package?
4 Replies
DrByte
DrByte12mo ago
You may have to explore the Monitor package's code to determine whether Url is truly "required" as the datatype to return from that Attribute, or whether you can safely just return a string.
bernhard
bernhardOP12mo ago
I can't overwrite it, since it has the fixed return type ?Url So I can't just return "string" in an overwriten class 😦
bernhard
bernhardOP12mo ago
Sorry, what?
Want results from more Discord servers?
Add your server