Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Include camel case attribute version#1676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
edvordo wants to merge3 commits intobarryvdh:master
base:master
Choose a base branch
Loading
fromedvordo:feature/model-include-camel-case-attribute-version

Conversation

@edvordo
Copy link
Contributor

@edvordoedvordo commentedFeb 12, 2025
edited
Loading

Summary

When model attribute is defined as either one of these

publicfunctiongetSomeValueAttribute() {return'some value';}
publicfunctionsomeValue():Attribute {return Attribute::get(fn () =>'some value');}

it is also possible to access the attribute via its camel case form, a.k.a

$post = Post::first();// both output the same value based on the attribute configuration// in the case of the above example: "some value"$post->some_value;$post->someValue;

I am aware ofmodel_camel_case_properties config option, but I don't want to have all attributes camel cased, just attributes.

Having this option improved the navigation to attributes, at least in my code base (don't have a publicaly facing repo to showcase, sorry).

Decided to add a configuration option for this and it's off by default, so existing projects would not have their models' DocBlocks populated with the camelCase version of attributes, but if this is deemed as too much, I am happy to remove it.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Existing tests have been adapted and/or new tests have been added
  • Code style has been fixed viacomposer fix-style

@edvordo
Copy link
ContributorAuthor

Anything I can do to get this merged?
Happy to close, if this is something that you don't wanna add, of course.

@barryvdh
Copy link
Owner

Why would you need both variants?

@edvordo
Copy link
ContributorAuthor

Good question, I technically don't need both.
I can update the PR to make this a toggle between the two.
Or make it a three way setting, a.k.a. one ofjust snake case,just camel case orsnake and camel case.

Or, as I said, I can close the PR, as in the month since I made it I've resorted to a model hook, that handles a very narrowed down version of this PR.

@mfn
Copy link
Collaborator

mfn commentedMar 17, 2025

PoV: hooks were introduced to give power to people to handle their special cases, as IMHO it doesn't make sense to provide all the options under the sun in a single package then no one else ever needs.

If hooks are missing something, maybe we can improve / refactor the code to allow supporting hose cases better.

All IMHO :)

@edvordo
Copy link
ContributorAuthor

I mean, if you willing to make a few of the model command methods public, so that I won't have to reimplement the wheel, that would be helpful.

These are some of the methods I could make use of:

  • getReturnTypeFromReflection
  • getAttributeTypes

Alternatively, there could be something similar to model hooks, but it would trigger for all props being added and it would get passed the full prop definition (name, return types, read, write, ..) so that i could just take it and make the modifications needed.

I don't know which you'd be okay with, might be neither and you may have a better idea, I'm just brainstorming.

@edvordo
Copy link
ContributorAuthor

Any kind of feedback would be welcome as to which direction I should take this. I don't want to spend time implementing something that is not desirable for you.

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@edvordo@barryvdh@mfn

[8]ページ先頭

©2009-2025 Movatter.jp