On laravel 10 site I use enums, defined like :
namespace AppEnums;
...
enum PointsStatusEnum: string
{
case STATUS_BEGIN = 'B';
...
public static function getCasesArray(): array
{
return self::cases();
}
}
When I define a method with this enum :
class ObjectName
{
public static function getData(PointsStatusEnum $employeeStatus): array
{
But When I call getData method with parameter of PointsStatusEnum with data from model
field I need to use tryFrom method :
PointsStatusEnum::getData(PointsStatusEnum::tryFrom($point->status))
I wonder if there is a way make automatic casting by setting $cast property in model definition?
"laravel/framework": "^10.48.12",
"php": "8.2"
Thanks in advance!