Skip to content

Consider adding default values to attributes #180

Open
@nandi95

Description

Search terms
attributes
default value

Is your feature request related to a problem? Please describe.
It isn't

Describe the solution you'd like
When defining a new model, the developer should have the option to define default values on the model. These defaults are sent to the server when saving the model so they should not be included in the original object when checking for changes

Describe how this would benefit the project/others
It would save the developer from having to pass in default values on constructing

Describe alternatives you've considered
none

Is there a currently a way to achieve this?

  • factories
  • custom user built method
  • an accessor
  • a custom caster

Additional context
Perhaps setting the attributes on the class definitely like public myAttribute = 1 would be the most intuitive given the current typing uses these attributes when set. This might be achieved by getting all the custom properties on the model which doesn't have getter and setter defined but a value.

Questions

  • Should these default values be passed to the accessors and should they be cast?
  • How should these default values be defined?

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthas workaroundThere is a way to achieve the aim

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions