У меня проблема с созданием препаратов на основе нескольких столбцов.Вот мой код и массив: -
$getdetails = OrdersProduct::with('getattributes')->get();
И мой OrdersProduct.php Файл модели
public function getattributes(){
return $this->hasMany('App\ProductsColor','product_id','product_id');
}
См. Массив ниже: -
Array
(
[0] => Array
(
[order_id] => 100015390
[product_id] => 1203
[product_size] => 12
[attributes] => Array
(
[0] => Array
(
[id] => 5748
[product_id] => 1203
[sku_website] => N7W84308-BLACK-10
[sku] => 8907613878595
[color] =>
[size] => 10
[price] => 2799
[stock] => 0
[ip_address] =>
[created_at] => 2018-08-07 16:15:36
[updated_at] => 2018-08-07 16:15:36
)
[1] => Array
(
[id] => 5749
[product_id] => 1203
[sku_website] => N7W84308-BLACK-12
[sku] => 8907613878601
[color] =>
[size] => 12
[price] => 2799
[stock] => 0
[ip_address] =>
[created_at] => 2018-08-07 16:15:37
[updated_at] => 2018-08-07 16:15:37
)
)
)
)
Мой ожидаемый вывод ниже: -
Array
(
[0] => Array
(
[order_id] => 100015390
[product_id] => 1203
[product_size] => 12
[attributes] => Array
(
[0] => Array
(
[id] => 5749
[product_id] => 1203
[sku_website] => N7W84308-BLACK-12
[sku] => 8907613878601
[color] =>
[size] => 12
[price] => 2799
[stock] => 0
[ip_address] =>
[created_at] => 2018-08-07 16:15:37
[updated_at] => 2018-08-07 16:15:37
)
)
)
)
Я хочу сравнить с product_id и product_size в форме таблицы order_products products_color, имеющей product_id и размер.спасибо