What seems to be the problem:
What types for casting properties are supported?
I am sure they are not the same as Laravel?
Are you using the latest version of Livewire:
Yes, sir!
Do you have any screenshots or code examples:
use Livewire\Component;
class Example extends Component
{
public $persons;
protected $casts = [
'persons' => 'integer',
];
}
Result:
ErrorException
Casting to type [integer] not supported.
Illuminate\View\Engines\CompilerEngine::handleViewException
vendor/livewire/livewire/src/DataCaster.php:40
...
protected function ensureTypeExists($type)
{
$isSupported = isset($this->casters[$type]) || class_exists($type);
throw_unless(
$isSupported,
====> new \Exception("Casting to type [{$type}] not supported.")
);
}
What types are currently supported?
EDIT:
In the source code, I see this the only ones that are supported is the date and collection types.
On the website is says the following:
Two common use-cases for this are working with date objects like
Carbon
instances, and dealing with Laravel collections
Not common use-cases, but the only use-cases
Kind regards,
Edwin