simplesquid / nova-enum-field

An enum field and filters for Laravel Nova.
MIT License
52 stars 26 forks source link

Ability to specify default value for filters #33

Closed ImJustToNy closed 3 years ago

ImJustToNy commented 3 years ago

Closes https://github.com/simplesquid/nova-enum-field/issues/32

To specify a default value, the user shall specify the third argument to EnumFilter's or EnumBooleanFilter's constructor. The way of creating default value is the same as for Filter and BooleanFilter classes in nova. Specifying default value works for basic constraint referencing UserType::Moderator and static function call UserType::Moderator(). This is a non-breaking change, since the third parameter is optional. I've briefly tested this enhancement. I've also added a small example to README.

Thanks for creating a cool package!

ImJustToNy commented 3 years ago

@mdpoulter, any chance to look at this PR? :)

mdpoulter commented 3 years ago

Hey @ImJustToNy. I will try to get to it this weekend 😄

mdpoulter commented 3 years ago

Hey @ImJustToNy . I've changed the API a little by swapping from the optional constructor parameter to an optional fluent method. Could you check and see if you're happy with this before I merge?

ImJustToNy commented 3 years ago

LGTM @mdpoulter :+1: