I am grateful in advance for any answer!
there are CATEGORIES
1⟶n
PRODUCTS (many)m⟶n
STORE (one)1⟶n
ADDRESS_CITY (many)CATEGORIES → PRODUCTS → STORES → ADDRESS_CITY
you must select all the CATEGORIES that have:
I tried to build a query, it does not work, there is only the hasManyThrough
method in the documentation
that jumps through 1 table, and there are more of them here. Or I'm even being stupid)
Help to build a query!
Another question: if I have 1 million products and 1000 stores, will the request be processed normally or do I need to look for other FEATURES:
id_city
in JSON in the PRODUCTSid_city
in JSON in the STORE$result = Category::where('on_off', 1)
->whereHas('product', function ($query) use ($city_one) {
$query->where('on_off', 1)
->whereHas('shop', function ($query) use ($city_one) {
$query->where('on_off', 1)
->whereHas('shop_map_point', function ($query) use ($city_one) {
$query->where('city_id', $city_one->id);
});
});
})
->get();