kirkbushell / eloquence

A drop-in library for certain database functionality in Laravel, that allows for extra features that may never make it into the main project.
MIT License
543 stars 58 forks source link

Added method so Model::create will properly translate camelCased attributes #16

Closed rogue780 closed 9 years ago

rogue780 commented 9 years ago

Some code of mine failed when using the CamelCaseModel because I was using Model::create() instead of assigning each attribute.

This code will make it so attributes are properly translated when using create() with the CamelCaseModel trait.

kirkbushell commented 9 years ago

Really appreciate your work on this @rogue780.

Couple of things - create/update goes via the fill() method, this then calls setAttribute which uses the $key to set $this->attributes[$key]. That's what you should be updating/overloading - that way said logic is left in a separate method and doesn't get in the way of users overloading their create methods.

If you can make those changes and write the appropriate tests - happy to then merge in the code.

rogue780 commented 9 years ago

@kirkbushell I've updated the PR. I'm not very good at unit tests so if I botched that part up, let me know.

kirkbushell commented 9 years ago

Hi @rogue780. On further note - eloquence already deals with the setAttribute method. I'll look at this a bit more myself - overloading fill() is not what I meant :)