INNER JOIN
clause. Am I correct in that? whereHas
clauses add a WHERE EXISTS
subquery, and with
clauses preform "eager loading" that just loads the relationship in separate queries.Obviously, there are a lot of cases where an
INNER JOIN
is going to be way more efficient than running a bunch of queries, so I have written a join
clause for these queries.-
Is it possible to use an eloquent relationship to define a
join
clause so that I don't have to rewrite the same join query every time I use the 2 tables together?
-
If not, why? It seems like joining 2 tables that are related would be something that should be standardized. I can't really see how adding a subquery like
WHERE EXISTS
would be a suitable substitute. (according to my tests, it generates much slower queries....)
from Latest question asked on Laravel tag.
via Skeets O'Reilly