framework icon indicating copy to clipboard operation
framework copied to clipboard

Consider adding default values to attributes

Open nandi95 opened this issue 4 years ago • 0 comments

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?

nandi95 avatar Jan 26 '22 09:01 nandi95