The Cast attribute allows you to cast your model's public properties to a specific type and also to type your public properties. It works the same way as it would be using the casts property on your model, but you can set it directly on your public properties.
A replacement for the fill method. It will cast your public properties and fill the model instance.
$product =newProduct();$product->castAndFill(['name'=>'Product 1','price'=>'10.99','category_id'=>'1','is_active'=>1,'promotion_expires_at'=>'2023-12-31 23:59:59','json_column'=>'{"foo":"bar"}',// You can also pass a JSON string]);$product->save();
castAndSet
This can be used to cast and set a single public property.