mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
修正集合类
This commit is contained in:
@@ -42,7 +42,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|||||||
|
|
||||||
public function toArray($allow = [])
|
public function toArray($allow = [])
|
||||||
{
|
{
|
||||||
return array_map(function ($value) {
|
return array_map(function ($value) use ($allow) {
|
||||||
return ($value instanceof Model || $value instanceof self) ? $value->toArray($allow) : $value;
|
return ($value instanceof Model || $value instanceof self) ? $value->toArray($allow) : $value;
|
||||||
}, $this->items);
|
}, $this->items);
|
||||||
}
|
}
|
||||||
@@ -225,11 +225,11 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($this->items as $row) {
|
foreach ($this->items as $row) {
|
||||||
$key = $value = null;
|
$key = $value = null;
|
||||||
$keySet = $valueSet = false;
|
$keySet = $valueSet = false;
|
||||||
if (null !== $index_key && array_key_exists($index_key, $row)) {
|
if (null !== $index_key && array_key_exists($index_key, $row)) {
|
||||||
$keySet = true;
|
$keySet = true;
|
||||||
$key = (string) $row[$index_key];
|
$key = (string)$row[$index_key];
|
||||||
}
|
}
|
||||||
if (null === $column_key) {
|
if (null === $column_key) {
|
||||||
$valueSet = true;
|
$valueSet = true;
|
||||||
@@ -344,8 +344,8 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|||||||
/**
|
/**
|
||||||
* 转换当前数据集为JSON字符串
|
* 转换当前数据集为JSON字符串
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $allow 允许输出的属性列表
|
* @param array $allow 允许输出的属性列表
|
||||||
* @param integer $options json参数
|
* @param integer $options json参数
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function toJson($allow = [], $options = JSON_UNESCAPED_UNICODE)
|
public function toJson($allow = [], $options = JSON_UNESCAPED_UNICODE)
|
||||||
@@ -369,6 +369,6 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|||||||
if ($items instanceof self) {
|
if ($items instanceof self) {
|
||||||
return $items->all();
|
return $items->all();
|
||||||
}
|
}
|
||||||
return (array) $items;
|
return (array)$items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user