如何在每个项目中添加新字段,我使用了 <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td background="[IMAGE GOES HERE]" style="background:url('[IMAGE GOES HERE]'); background-image: url('[IMAGE GOES HERE]');">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:[ADD WIDTH OF IMAGE];height:[ADD IMAGE HEIGHT];">
<v:fill type="frame" src="[IMAGE GOES HERE]" color="[FALLBACK COLOR]" />
<v:textbox inset="0,0,0,0">
<![endif]-->
[HTML CONTENT HERE]
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</tbody>
</table>
,但它只添加了最后一项。
put()
结果:
return self::where('latest', 1)
->where('competitionId',$competitionId)
->orderBy('won','desc')
->orderBy('teamName','asc')
->get(['teamName','played','won','lost','percentage', 'streak'])
->put('test', ['123', '345'])
->toJson();
预期产出:
{
"0": {"teamName": "A"},
"1": {"teamName": "B"},
"2": {"teamName": "C", "test": ['123', '345']},
}
答案 0 :(得分:10)
您可以使用map()
->map(function ($item) {
$item['test'] = ['123', '345'];
return $item;
});