Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document withAttributes #10148

Open
wants to merge 1 commit into
base: 11.x
Choose a base branch
from
Open

Document withAttributes #10148

wants to merge 1 commit into from

Conversation

tontonsb
Copy link
Contributor

An attempt to document the feature added in laravel/framework#53720. I wrote everything that felt like it might be useful. And tried to put it in places where a reader might look exactly when this could be useful for them. Some of my reasoning below.

The initial description of withAttributes is in the scopes' section of eloquent.md because IMO that's where the simplest use of this feature makes sense.

The feature feels most useful inside relationships so I mentioned it in that doc as well. But I added a broader section introducing the various options of "scoping" relationships. I suspect this might be useful as I've seen many new devs viewing the relationship methods as some special syntax that may only include the $this->relationshipMethod(RelatedModel::class); and nothing else.

I added that section at the end of the first batch of relationship methods as that's where the reader seems familiar enough with relationships themselves. In the next section (many to many) I added a note about withPivotValue while referring to the same concept of being "scoped" that was introduced earlier.

...or maybe these are constrained relationships, not scoped ones?

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.

1 participant