You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a model with an url attribute uses the Illuminate\Database\Eloquent\Casts\AsUri cast, it can't be used in a Livewire component like a Filament form, because this error is thrown: Property type not supported in Livewire for property.
Adding a serialize method to the cast class to serialize to string solves the problem:
class AsUri implements Castable
{
public static function castUsing(array $arguments)
{
return new class implements CastsAttributes, SerializesCastableAttributes
{
public function get($model, $key, $value, $attributes)
{
return isset($value) ? new Uri($value) : null;
}
public function set($model, $key, $value, $attributes)
{
return isset($value) ? (string) $value : null;
}
public function serialize($model, $key, $value, $attributes)
{
return isset($value) ? (string) $value : null;
}
};
}
}
So, must must AsHtmlString, AsStringable and AsUri casts implement SerializesCastableAttributes?. Don't know if this can introduce any kind of issue...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
If a model with an
url
attribute uses theIlluminate\Database\Eloquent\Casts\AsUri
cast, it can't be used in a Livewire component like a Filament form, because this error is thrown:Property type not supported in Livewire for property
.Adding a
serialize
method to the cast class to serialize to string solves the problem:So, must must
AsHtmlString
,AsStringable
andAsUri
casts implementSerializesCastableAttributes
?. Don't know if this can introduce any kind of issue...Beta Was this translation helpful? Give feedback.
All reactions