标签:用法 air cti product collect code 如何 设置 col
pluck方法为给定键获取所有集合值:
$collection = collect([
[‘product_id‘ => ‘prod-100‘, ‘name‘ => ‘Desk‘],
[‘product_id‘ => ‘prod-200‘, ‘name‘ => ‘Chair‘],
]);
$plucked = $collection->pluck(‘name‘);
$plucked->all();
// [‘Desk‘, ‘Chair‘]
还可以指定你想要结果集合如何设置键:
$plucked = $collection->pluck(‘name‘, ‘product_id‘);
$plucked->all();
// [‘prod-100‘ => ‘Desk‘, ‘prod-200‘ => ‘Chair‘]
标签:用法 air cti product collect code 如何 设置 col
原文地址:https://www.cnblogs.com/caibaotimes/p/14022451.html