Skip to content

Conversation

@janhartigan
Copy link
Contributor

In this commit a previously undocumented feature of the mutator attributes was removed. Prior to this commit, it was possible to reference accessors using snake, camel, and studly cases. For example:

protected $appends = ['first_name', 'lastName', 'FullName'];

public function getFirstNameAttribute() {...}
public function getLastNameAttribute() {...}
public function getFullNameAttribute() {...}

This would work and append the key that you specified into the resulting array:

[
    'first_name' => ...,
    'lastName' => ...,
    'FullName' => ...,
]

After this commit, it only accepts snake case. I imagine we aren't the only ones using this (and we are using it rather widely in our systems), so I put together a pull request that keeps all the current features and allows for this. I added a test to verify that it works as well. Let me know if you need anything else or if you have any comments/questions/concerns.

taylorotwell added a commit that referenced this pull request Dec 18, 2014
Allowing for camel and studly-cased mutator attributes
@taylorotwell taylorotwell merged commit 1dcb14b into laravel:4.2 Dec 18, 2014
@taylorotwell
Copy link
Member

Ah. We'll merge this for 4.2 but remove it in 5.0 since it really makes the whole point of the optimization moot.

@janhartigan
Copy link
Contributor Author

Cheers, thanks Taylor.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GrahamCampbell sorry, I'll try to avoid this in the future :)

@andrewmclagan
Copy link

Just to clarify, we are not able to use camel case accessors or mutators in 5.x.x? Is there a workaround, currently in upgrade and current code style uses camel case?

@janhartigan
Copy link
Contributor Author

Works fine for me. They merged this PR.

@andrewmclagan
Copy link

Yeah, i gave it a run and seems fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants