We define our child types based on values from phpenum, however all constants are marked as private and cannot be used outside of the enum (this enforces us the use the method instead of the private constant).
But expressions are not allowed as field default values, so we would like to override the getChildTypes method.
e.g.
...
class Vehicle extends Model
{
use HasChildren;
protected $childTypes = [
EnumVehicle::CAR => Car::class
];
}
Becomes in our case
e.g.
...
class Vehicle extends Model
{
use HasChildren;
public function getChildTypes(): array
{
return [
EnumVehicle::CAR()->getValue() => Car::class
];
}
}
We define our child types based on values from phpenum, however all constants are marked as private and cannot be used outside of the enum (this enforces us the use the method instead of the private constant).
But expressions are not allowed as field default values, so we would like to override the getChildTypes method.
e.g.
Becomes in our case e.g.