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

Improve relationship calling. #910

Open
josephmancuso opened this issue Nov 28, 2024 · 3 comments
Open

Improve relationship calling. #910

josephmancuso opened this issue Nov 28, 2024 · 3 comments
Labels
enhancement A feature that exists, works as intended but needs to be improved feature request A feature that does not yet exist but will be a good addition to the library major This issue can only be done in a major release because there are some breaking changes

Comments

@josephmancuso
Copy link
Member

Need to modify how relationships are called to act more like old Orator or Laravel's Eloquent

user = User.find(1)
user.relationship().where("column", "value").get()

Also need to simplify the relationship logic

@josephmancuso josephmancuso added enhancement A feature that exists, works as intended but needs to be improved feature request A feature that does not yet exist but will be a good addition to the library major This issue can only be done in a major release because there are some breaking changes labels Nov 28, 2024
@Marlysson
Copy link
Contributor

Interesting, was found a way to act like that? ( in past the language limitation avoid programming things like this )

@circulon
Copy link
Contributor

user = User.find(1)
user.relationship().where("column", "value").get()

@josephmancuso
Isn't this kind of filtering is already implemented for the xxx_many relationships as they return a Collection?
example

user = User.find(1)
masonite_posts = user.posts.where("subject", "masonite").all()

we already have tests which valudate this too

Or am I not understanding this correctly?

Interestingly I note that Collection has no .get() method?

@josephmancuso
Copy link
Member Author

josephmancuso commented Dec 13, 2024

@circulon

masonite_posts = user.posts.where("subject", "masonite").all()

this is filtering the collection. i want it to work slightlt differently where this returns a collection:

masonite_posts = user.posts

but this retirns a query builder

masonite_posts = user.posts()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature that exists, works as intended but needs to be improved feature request A feature that does not yet exist but will be a good addition to the library major This issue can only be done in a major release because there are some breaking changes
Projects
Status: Todo
Development

No branches or pull requests

3 participants