You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In long-term projects, Enums can accumulate values that are no longer used. Although these values can be deleted, sometimes they can't be because it may affect other systems. In particular, in Laravel-Enum, trying to create an instance with an undefined value causes an error.
Proposed Solution
I propose to add a new $hidden property to Laravel-Enum classes to hide unwanted enum values. This property is inspired by the $hidden attribute in Laravel's Eloquent Model.
# before
UserType::asSelectArray()
array:4 [
"administrator" => "administrator description",
"moderator" => "moderator description",
"subscriber" => "subscriber description",
"super_administrator" => "super administrator description",
]
(※ ↑ assuming the description is defined in enums.php)
# after
UserType::asSelectArray();
array:4 [
"administrator" => "administrator description",
"super_administrator" => "super administrator description",
]
This will allow us to hide values that are no longer needed, making the Enums more manageable within the project. In the future, providing makeHidden and makeVisible methods would allow dynamic toggling of visibility.
Preliminary Implementation
I have implemented a basic version of this feature in my fork of the repository, which can be found here. This implementation is not final, but it demonstrates how the $hidden property can be used.
I would like to discuss this feature and continue the implementation with feedback and guidance from the community.
The text was updated successfully, but these errors were encountered:
Thank you for offering this convenient package.
Problem
In long-term projects, Enums can accumulate values that are no longer used. Although these values can be deleted, sometimes they can't be because it may affect other systems. In particular, in Laravel-Enum, trying to create an instance with an undefined value causes an error.
Proposed Solution
I propose to add a new $hidden property to Laravel-Enum classes to hide unwanted enum values. This property is inspired by the
$hidden
attribute in Laravel's Eloquent Model.Example Usage:
This will allow us to hide values that are no longer needed, making the Enums more manageable within the project. In the future, providing makeHidden and makeVisible methods would allow dynamic toggling of visibility.
Preliminary Implementation
I have implemented a basic version of this feature in my fork of the repository, which can be found here. This implementation is not final, but it demonstrates how the
$hidden
property can be used.I would like to discuss this feature and continue the implementation with feedback and guidance from the community.
The text was updated successfully, but these errors were encountered: