Properties

$items

$items : array

数据集数据

Type

array

Methods

__construct()

__construct(  $items = array()) 

Parameters

$items

make()

make(  $items = array()) 

Parameters

$items

isEmpty()

isEmpty() : boolean

是否为空

Returns

boolean

toArray()

toArray() 

all()

all() 

merge()

merge(mixed  $items) : static

合并数组

Parameters

mixed $items

Returns

static

flip()

flip() : static

交换数组中的键和值

Returns

static

dictionary()

dictionary(mixed  $items = null, string  $indexKey = null) : array

按指定键整理数据

Parameters

mixed $items

数据

string $indexKey

键名

Returns

array

diff()

diff(mixed  $items, string  $indexKey = null) : static

比较数组,返回差集

Parameters

mixed $items

数据

string $indexKey

指定比较的键名

Returns

static

intersect()

intersect(mixed  $items, string  $indexKey = null) : static

比较数组,返回交集

Parameters

mixed $items

数据

string $indexKey

指定比较的键名

Returns

static

keys()

keys() : array

返回数组中所有的键名

Returns

array

pop()

pop() : mixed

删除数组的最后一个元素(出栈)

Returns

mixed

reduce()

reduce(callable  $callback, mixed  $initial = null) : mixed

通过使用用户自定义函数,以字符串返回数组

Parameters

callable $callback
mixed $initial

Returns

mixed

reverse()

reverse() : static

以相反的顺序返回数组。

Returns

static

shift()

shift() : mixed

删除数组中首个元素,并返回被删除元素的值

Returns

mixed

push()

push(mixed  $value, mixed  $key = null) : void

在数组结尾插入一个元素

Parameters

mixed $value
mixed $key

chunk()

chunk(integer  $size, boolean  $preserveKeys = false) : static

把一个数组分割为新的数组块.

Parameters

integer $size
boolean $preserveKeys

Returns

static

unshift()

unshift(mixed  $value, mixed  $key = null) : void

在数组开头插入一个元素

Parameters

mixed $value
mixed $key

each()

each(callable  $callback) : $this

给每个元素执行个回调

Parameters

callable $callback

Returns

$this

map()

map(callable|null  $callback) : static

用回调函数处理数组中的元素

Parameters

callable|null $callback

Returns

static

filter()

filter(callable|null  $callback = null) : static

用回调函数过滤数组中的元素

Parameters

callable|null $callback

Returns

static

where()

where(string  $field, mixed  $operator, mixed  $value = null) : static

根据字段条件过滤数组中的元素

Parameters

string $field

字段名

mixed $operator

操作符

mixed $value

数据

Returns

static

column()

column(mixed  $columnKey, mixed  $indexKey = null) : array

返回数据中指定的一列

Parameters

mixed $columnKey

键名

mixed $indexKey

作为索引值的列

Returns

array

sort()

sort(callable|null  $callback = null) : static

对数组排序

Parameters

callable|null $callback

Returns

static

order()

order(string  $field, string  $order = null, boolean  $intSort = true) : $this

指定字段排序

Parameters

string $field

排序字段

string $order

排序

boolean $intSort

是否为数字排序

Returns

$this

shuffle()

shuffle() : static

将数组打乱

Returns

static

slice()

slice(integer  $offset, integer  $length = null, boolean  $preserveKeys = false) : static

截取数组

Parameters

integer $offset
integer $length
boolean $preserveKeys

Returns

static

offsetExists()

offsetExists(  $offset) 

Parameters

$offset

offsetGet()

offsetGet(  $offset) 

Parameters

$offset

offsetSet()

offsetSet(  $offset,   $value) 

Parameters

$offset
$value

offsetUnset()

offsetUnset(  $offset) 

Parameters

$offset

count()

count() 

getIterator()

getIterator() 

jsonSerialize()

jsonSerialize() 

toJson()

toJson(integer  $options = JSON_UNESCAPED_UNICODE) : string

转换当前数据集为JSON字符串

Parameters

integer $options

json参数

Returns

string

__toString()

__toString() 

load()

load(mixed  $relation) : $this

延迟预载入关联查询

Parameters

mixed $relation

关联

Returns

$this

hidden()

hidden(array  $hidden = array(), boolean  $override = false) : $this

设置需要隐藏的输出属性

Parameters

array $hidden

属性列表

boolean $override

是否覆盖

Returns

$this

visible()

visible(array  $visible = array(), boolean  $override = false) : $this

设置需要输出的属性

Parameters

array $visible
boolean $override

是否覆盖

Returns

$this

append()

append(array  $append = array(), boolean  $override = false) : $this

设置需要追加的输出属性

Parameters

array $append

属性列表

boolean $override

是否覆盖

Returns

$this

withAttr()

withAttr(string|array  $name, callable  $callback = null) : $this

设置数据字段获取器

Parameters

string|array $name

字段名

callable $callback

闭包获取器

Returns

$this

convertToArray()

convertToArray(mixed  $items) : array

转换成数组

Parameters

mixed $items

Returns

array