Cast attribute Collection of enum #837
-
When I use Collection with enum, it return an error
Is there a way to cast it? enum GenderEnum: string
{
case rock = 'rock';
case pop = 'pending';
case classic = 'classic';
}
class SongDTO extends Data
{
/**
* @param Collection<GenderEnum> $gender
*/
public function __construct(
public readonly string $term,
public readonly Collection $gender,
) {
}
}
$song = SongDTO::validateAndCreate([
'term' => 'Birthday',
'gender' => ['rock', 'pop', 'classic'],
]);
dd($song); |
Beta Was this translation helpful? Give feedback.
Answered by
albertcito
Aug 13, 2024
Replies: 1 comment
-
I added this value in the configuration file, and it works (Doc):
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
albertcito
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I added this value in the configuration file, and it works (Doc):