Код: Выделить всё
product_id ingredient_id quantity
---------- ------------- --------
1 1 100
1 3 50
1 4 20
2 1 80
2 2 70
Код: Выделить всё
id name price
----- ------ -------
1 1 100
1 3 50
1 4 20
2 1 80
Код: Выделить всё
id name qty
----- ------ -------
1 1 100
1 3 200
1 4 200
2 1 800
Код: Выделить всё
[1] => Array
(
[ingredient_id] => Array
(
[0]=>1
[1]=>3
[2]=>4
),
[quantity] => Array
(
[0]=>100
[1]=>50
[2]=>20
)
)
[2] => Array
(
[ingredient_id] => Array
(
[0]=>1
[1]=>2
),
[quantity] => Array
(
[0]=>80
[1]=>70
)
)
< /code>
Я уже пробовал, но это был не идеальный запрос. < /p>
$data = DB::table('product_wise_ingredient_measurements')
->join('products', 'products.id', '=', 'product_wise_ingredient_measurements.products_id')
->join('ingredients', 'ingredients.id', '=', 'product_wise_ingredient_measurements.ingredients_id')
->select('product_wise_ingredient_measurements.*', 'products.product_name as products_name', 'ingredients.name as ingredients_name')
->where('product_wise_ingredient_measurements.products_id','=',$pro_wise_ingre_measurement->products_id)
->get();
Подробнее здесь: https://stackoverflow.com/questions/709 ... in-laravel
Мобильная версия