MattB
3 weeks ago
818
19
Eloquent

Multiple table queries

Posted 3 weeks ago by MattB

Ok, so I don't know if this can be done, but I need to combine the results of 2 Where clauses from 2 tables into one variable.

So far I have this working to query one table:

$allCompanies = Products::where('category_id', $id->id)->groupBy('company_id')->get();

And this for the other:

$companies = Company::where('visible', 0)->get();

But is there any way to get them into the same query string? Something like so I can get where the ID matches the ID column in one table AND where visible is 0 in the other?

Please sign in or create an account to participate in this conversation.