-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Suggestion: Inform users about MySQL's View (virtual tables)? #17
Comments
Is this a suggestion for this repository or the Laravel documentation? |
Suggestion/Note in this repo to point out that MySQL's view is a possible solution /workaround for highly advanced relationships (with conditions, or unions etc) While being able to work with eager loading and then of course when Laravel's Migrations officially support creating MySQL Views + documentation then a lot of us would avoid this headache... Did you get my reasoning to use MySQL's View? |
I really like the view idea, but I don't think it belongs in this repository. What would be an example for a relationship with conditions? |
You're right, its not for this repo but it is an alternative solution Note that the key problem to solve is advanced/conditional deep relationships. MySQL queries has no issues with this but eloquent wasn't built for it. (which this repo is trying to solve) Example: BillingAccount has many Orders As you can see, a BillingAccount has Ordered some Coupons which has an Invoice that can be pending Payment or already paid in full (multiple Payments to cover single Invoice) With MySQL view,
In total, 2 fake pivot tables |
Using MySQL view as pivot table will also solve the Union problem mentioned in: #8 |
I've created a package for merging relationships using views: |
Hi @staudenmeir
I really appreciate the repo
Out of desperation, I've moved a lot of advanced relationships to depend on MySQL's View instead
Creating a fake table, to trick laravel, eager loading, etc has been working
Have been depending on subquery joins lately
also, users should be discouraged to use
appends()
and useleftJoin()
insteadI guess Laravel is built without having deep relationships in mind, which leaves out a lot of functions, causing a lot of limitations
Now I can even union relationships, adding where clauses for the relationships etc.
Would be nice if I knew earlier that Laravel's not capable and MySQL's View is there to help
If I'm right, please add a note to point out MySQL's View is the way to go if the relations are to advanced
In fact, I think Laravel should allow Migrations to create virtual tables
Part of my code that creates a fake relationship, based on the distance of an Address's GPS, to a Polygon of the ServiceArea table. The distance must be less than 0.05
then:
The text was updated successfully, but these errors were encountered: