Closed dpetrovaliev closed 3 years ago
Hey,
have you tried extending the EnumCollectionCast
?
https://github.com/spatie/laravel-enum/blob/master/src/Casts/EnumCollectionCast.php
As a PR I think that adding a config to the options would be a good solution.
Like the nullable
flag - the user could provide json
or comma
. 🤔
I think that set
would be an irritating and misleading and too specific naming, that's why I think that comma
is fine.
The default would be json
.
Hey, @Gummibeer
I've tried your suggestion and it works but looking at the definition it doesn't make any sense to me personally:
protected $casts = [
'set_of_enums' => StatusEnum::class.':collection,comma',
'nullable_set_of_enums' => StatusEnum::class.':collection,comma,nullable',
];
Why don't we try to define it as a new type data type? For example:
'set_of_enums' => StatusEnum::class.':set_collection'
Hi, I have the following case:
I have a table with a column type set which is comma-separated values ex. "MALE,FEMALE". Would be great if there is an additional
cast
for a column with that column type.