Casting properties types

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',


Casting to type [integer] not supported.



protected function ensureTypeExists($type)
    $isSupported = isset($this->casters[$type]) || class_exists($type);


====>   new \Exception("Casting to type [{$type}] not supported.")



What types are currently supported?

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 :wink:

Kind regards,

It’s super simple to make your own

class IntegerCaster implements Castable
    public function cast($value)
        return (int) $value;

    public function uncast($value)
        return $value;