I have the following data:
array:4 [
0 => array:8 [
"id" => 135
"stock_id" => 50
"quantity" => 1
"product_id" => 1
"size_id" => 1
"colour_id" => 3
"colour" => array:2 [
"id" => 3
"name" => "小豹纹"
]
"size" => array:2 [
"id" => 1
"name" => "70A"
]
]
1 => array:8 [
"id" => 136
"stock_id" => 50
"quantity" => 5
"product_id" => 1
"size_id" => 9
"colour_id" => 4
"colour" => array:2 [
"id" => 4
"name" => "裸灰色"
]
"size" => array:2 [
"id" => 9
"name" => "80B"
]
]
2 => array:8 [
"id" => 137
"stock_id" => 50
"quantity" => 3
"product_id" => 2
"size_id" => 12
"colour_id" => 1
"colour" => array:2 [
"id" => 1
"name" => "黑色"
]
"size" => array:2 [
"id" => 12
"name" => "85C"
]
]
3 => array:8 [
"id" => 138
"stock_id" => 50
"quantity" => 2
"product_id" => 4
"size_id" => 16
"colour_id" => 2
"colour" => array:2 [
"id" => 2
"name" => "肤色"
]
"size" => array:2 [
"id" => 16
"name" => "XL"
]
]
]
I am generating Excel sheets using Laravel-Excel (http://ift.tt/1kdyvgZ).
A sample of the Excel sheets structure looks like this:
...
<!--ROW 7-->
<tr>
<td>JW1501</td>
<td>呼吸款</td>
<td>黑色</td>
<td>80A</td>
<td>Q!!</td>
<td>79</td>
<td>JW1502</td>
<td>高端款</td>
<td>裸灰色</td>
<td>80A</td>
<td>Q!!</td>
<td>99</td>
<td>JW1501-1</td>
<td>呼吸款内裤</td>
<td>黑色</td>
<td>XL</td>
<td>Q!!</td>
<td>20</td>
</tr>
...
The "Q!!" needs to be replaced by "quantity" found in the array but only if it matches the corresponding product_id, colour_id and size_id. I thought about doing this without those fields in the array and just hard coding it e.g. ->where('product_id', 2) etc.
How can I achieve this?
Also the order in which things appear in the array is random.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire