mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge pull request #17813 from filamentphp/fix/string-state-cast-enum-support
fix: String state cast enum support
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Filament\Schemas\Components\StateCasts;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Schemas\Components\StateCasts\Contracts\StateCast;
|
||||
|
||||
class StringArrayStateCast implements StateCast
|
||||
@@ -26,6 +27,10 @@ class StringArrayStateCast implements StateCast
|
||||
return $carry;
|
||||
}
|
||||
|
||||
if ($stateItem instanceof BackedEnum) {
|
||||
$stateItem = $stateItem->value;
|
||||
}
|
||||
|
||||
$carry[] = strval($stateItem);
|
||||
|
||||
return $carry;
|
||||
@@ -54,6 +59,10 @@ class StringArrayStateCast implements StateCast
|
||||
return $carry;
|
||||
}
|
||||
|
||||
if ($stateItem instanceof BackedEnum) {
|
||||
$stateItem = $stateItem->value;
|
||||
}
|
||||
|
||||
$carry[] = strval($stateItem);
|
||||
|
||||
return $carry;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Filament\Schemas\Components\StateCasts;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Schemas\Components\StateCasts\Contracts\StateCast;
|
||||
|
||||
class StringStateCast implements StateCast
|
||||
@@ -16,6 +17,10 @@ class StringStateCast implements StateCast
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($state instanceof BackedEnum) {
|
||||
$state = $state->value;
|
||||
}
|
||||
|
||||
return strval($state);
|
||||
}
|
||||
|
||||
@@ -25,6 +30,10 @@ class StringStateCast implements StateCast
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($state instanceof BackedEnum) {
|
||||
$state = $state->value;
|
||||
}
|
||||
|
||||
return strval($state);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user