Answer the question
In order to leave comments, you need to log in
How to construct a query in which leftJoin should take the name of the second table from the cell of the first?
There is a pivot table of products from which we select id, table values.
Product details are stored in tables whose names are stored in the summary in the table field.
There is a task to choose products of a certain brand.
The beginning looks like this
$productsQuery = \Db::table('im_depend');
//нужны продукты только со статусом ниже 3.
$brand_products=$productsQuery->where('.status', '<', 3)
->select('id', 'table')
?????????????????
->where('brand', '=', $brand)->get();
Answer the question
In order to leave comments, you need to log in
I doubt that it is generally possible in one query to use the data stored in the table as the name of the database objects.
Most likely, you will have to make additional queries, ideally one for each product table.
In general, things like goods should be stored using the EAV structure.
It is better to change the tags for the question, post a dump of the tables.
The problem is to understand what kind of request you need to write in general, and how to arrange it in Laravel is the tenth thing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question