class Column implements Structable

列展示以及渲染, 当前的目的是使用前端方式渲染, 而不是依靠于 v-html 或者是后端生成

Traits

Constants

NAME_ACTION

Properties

Filter $filter from  HasHeader
protected array $headers from  HasHeader
protected bool $ellipsis from  AsText
protected bool $copyable 可复制的 from  AsText
static array $renderers

renders for grid column.

static array $defined

Defined columns.

string read-only $name 当前列的名称
string read-only $label 标签
protected mixed $original

Original value of column.

string read-only $relation 当前关系
protected string $relationColumn 关系列
protected Closure[] $renderCallbacks
protected bool $sortable
protected bool $searchable

todo 可搜索的

protected int $width 定义宽度
protected string $align 对齐方式
bool read-only $relationMany 是否是一对多关系

Methods

$this
addHeader(string|Renderable|Htmlable $header)

Add contents to column header.

bindFilterQuery(QueryModel $model)

Add a binding based on filter to the model query.

string
renderHeader()

Render Column header.

getHeader()

No description

$this
addFilter($type = null, $formal = null)

添加搜索到列 Header

ellipsis()

隐藏字符展示

from  AsText
copyable()

可复制

from  AsText
asHtml(Closure $closure)

No description

from  AsText
html(Closure $closure) deprecated

No description

from  AsText
asKv(array $values, string $default = '')

使用KV进行替换输出, 并可以指定默认值

from  AsText
asHidden(Closure $cb = null)

隐藏数值

from  AsText
usingKv(array $values, string $default = '') deprecated

No description

from  AsText
editAsText(Closure $cb = null, Closure $disableCb = null)

追加编辑模式

from  AsText
editAsSelect(Closure $cb = null, Closure $disableCb = null)

追加编辑模式

from  AsSelect
asOnOff()

渲染为开关

from  AsOnOff
editAsOnOff(Closure $cb = null, Closure $disableCb = null)

追加编辑模式

from  AsOnOff
filesize() deprecated

显示为友好的文件大小

from  AsMath
asFilesize()

显示为友好的文件大小

from  AsMath
asDate(string $format)

Returns a string formatted according to the given format string.

from  AsDate
asDiffForHumans(null $locale = null)

Return a human readable format time.

from  AsDate
date(string $format) deprecated

No description

from  AsDate
diffForHumans(null $locale = null) deprecated

No description

from  AsDate
quickId($large = false)

渲染为ID

from  AsQuick
quickTitle($large = false)

No description

from  AsQuick
quickDatetime()

渲染为 Datetime 时间

from  AsQuick
quickIcon($num = 3, $fixed = true)

定义快捷样式

from  AsQuick
asDefaultDisabled($cb = null, $disableCb = null)

No description

asLink(Closure $cb = null, string $target = '_blank')

渲染为链接

from  AsUrl
asDownload(string $server = '')

下载

from  AsUrl
asImage(string $server = '', int $width = 60, int $height = 60, string $suffix = '')

No description

from  AsImage
asAction(Closure $cb)

调用 Actions 预览定义的操作

from  AsAction
__construct(string $name, string $label = '')

No description

width(int $width, bool $fixed = false)

设置列宽度, 单个按钮 最优宽度 60(图标), 每个按钮增加 45 宽度 Datetime 最优宽度 170

align(string|int $align)

设置展示位置, 默认 left, 可选 [left,center,right]

sortable()

标识列为可排序

fixed(string $position = 'right')

标识列为可fix 显示, 默认是右侧, 可以设置为 [left, right]

$this
filter(null $builder = null)

列搜索工具

searchable()

Set column as searchable.

setType($type)

No description

void
setEditAttr($attr)

设置编辑属性

struct()

可结构化并返回

display(Closure $callback)

定义回调

fillVal($row)

No description

$this
__call(string $method, array $arguments)

Passes through all unknown calls to builtin renders or supported render.

string
__get(string $key)

获取类属性

static 
extend($name, $render)

Extend column render.

static 
define(string $name, mixed $definition)

定义全局列渲染

setRelation(string $relation, string $field, bool $many = false)

设置 Relation

bool
isRelation()

If this column is relation column.

bool
hasRenderCallbacks()

If has display callbacks.

mixed
callDisplayCallbacks(mixed $value, $row)

调用所有的列渲染回调, 因为 row 可能未自定义的 Query 渲染, 所以返回可能是数组, 这里使用 collect 包裹处理

bool
isDefinedColumn()

当前列是否在全局定义中

useDefinedColumn()

使用全局列定义

resolveRender(string $method, array $arguments)

Find a render to display column.

callSupportRender(string $method, array $arguments)

Call Illuminate/Support.

callBuiltinRender(string|Closure $abstract, array $arguments)

Call Builtin.

Details

in HasHeader at line 30
$this addHeader(string|Renderable|Htmlable $header)

Add contents to column header.

Parameters

string|Renderable|Htmlable $header

Return Value

$this

in HasHeader at line 46
bindFilterQuery(QueryModel $model)

Add a binding based on filter to the model query.

Parameters

QueryModel $model

in HasHeader at line 58
string renderHeader()

Render Column header.

Return Value

string

in HasHeader at line 73
getHeader()

No description

in HasHeader at line 82
protected $this addFilter($type = null, $formal = null)

添加搜索到列 Header

Parameters

$type
$formal

Return Value

$this

in AsText at line 31
AsText ellipsis()

隐藏字符展示

Return Value

AsText

in AsText at line 41
AsText copyable()

可复制

Return Value

AsText

in AsText at line 48
AsText asHtml(Closure $closure)

No description

Parameters

Closure $closure

Return Value

AsText

in AsText at line 59
AsText html(Closure $closure) deprecated

deprecated

No description

Parameters

Closure $closure

Return Value

AsText

in AsText at line 70
AsText asKv(array $values, string $default = '')

使用KV进行替换输出, 并可以指定默认值

Parameters

array $values
string $default

Return Value

AsText

in AsText at line 87
HiddenOption asHidden(Closure $cb = null)

隐藏数值

Parameters

Closure $cb

Return Value

HiddenOption

in AsText at line 112
AsText usingKv(array $values, string $default = '') deprecated

deprecated

No description

Parameters

array $values
string $default

Return Value

AsText

in AsText at line 120
EditOption editAsText(Closure $cb = null, Closure $disableCb = null)

追加编辑模式

Parameters

Closure $cb
Closure $disableCb

Return Value

EditOption

in AsSelect at line 13
SelectOption editAsSelect(Closure $cb = null, Closure $disableCb = null)

追加编辑模式

Parameters

Closure $cb
Closure $disableCb

Return Value

SelectOption

in AsOnOff at line 14
AsOnOff asOnOff()

渲染为开关

Return Value

AsOnOff

in AsOnOff at line 30
OnOffOption editAsOnOff(Closure $cb = null, Closure $disableCb = null)

追加编辑模式

Parameters

Closure $cb
Closure $disableCb

Return Value

OnOffOption

in AsMath at line 16
AsMath filesize() deprecated

deprecated 4.0-dev

显示为友好的文件大小

Return Value

AsMath

in AsMath at line 25
AsMath asFilesize()

显示为友好的文件大小

Return Value

AsMath

in AsDate at line 17
AsDate asDate(string $format)

Returns a string formatted according to the given format string.

Parameters

string $format

Return Value

AsDate

in AsDate at line 32
AsDate asDiffForHumans(null $locale = null)

Return a human readable format time.

Parameters

null $locale

Return Value

AsDate

in AsDate at line 48
AsDate date(string $format) deprecated

deprecated 4.0-dev

No description

Parameters

string $format

Return Value

AsDate

in AsDate at line 59
AsDate diffForHumans(null $locale = null) deprecated

deprecated 4.0-dev

No description

Parameters

null $locale

Return Value

AsDate

in AsQuick at line 16
AsQuick quickId($large = false)

渲染为ID

Parameters

$large

Return Value

AsQuick

in AsQuick at line 27
AsQuick quickTitle($large = false)

No description

Parameters

$large

Return Value

AsQuick

in AsQuick at line 38
AsQuick quickDatetime()

渲染为 Datetime 时间

Return Value

AsQuick

in AsQuick at line 48
AsQuick quickIcon($num = 3, $fixed = true)

定义快捷样式

Parameters

$num
$fixed

Return Value

AsQuick

in AsDefault at line 10
protected AsDefault asDefaultDisabled($cb = null, $disableCb = null)

No description

Parameters

$cb
$disableCb

Return Value

AsDefault

渲染为链接

Parameters

Closure $cb
string $target

Return Value

AsUrl

in AsUrl at line 43
AsUrl asDownload(string $server = '')

下载

Parameters

string $server 服务器地址

Return Value

AsUrl

in AsImage at line 17
AsImage asImage(string $server = '', int $width = 60, int $height = 60, string $suffix = '')

No description

Parameters

string $server
int $width
int $height
string $suffix

Return Value

AsImage

in AsAction at line 13
AsAction asAction(Closure $cb)

调用 Actions 预览定义的操作

Parameters

Closure $cb

Return Value

AsAction

at line 158
__construct(string $name, string $label = '')

No description

Parameters

string $name
string $label

at line 172
Column width(int $width, bool $fixed = false)

设置列宽度, 单个按钮 最优宽度 60(图标), 每个按钮增加 45 宽度 Datetime 最优宽度 170

Parameters

int $width 宽度
bool $fixed 是否是固定宽度

Return Value

Column

at line 188
Column align(string|int $align)

设置展示位置, 默认 left, 可选 [left,center,right]

Parameters

string|int $align

Return Value

Column

at line 198
Column sortable()

标识列为可排序

Return Value

Column

at line 210
Column fixed(string $position = 'right')

标识列为可fix 显示, 默认是右侧, 可以设置为 [left, right]

Parameters

string $position

Return Value

Column

at line 222
$this filter(null $builder = null)

列搜索工具

Parameters

null $builder

Return Value

$this

at line 233
Column searchable()

Set column as searchable.

Return Value

Column

at line 239
setType($type)

No description

Parameters

$type

at line 249
void setEditAttr($attr)

设置编辑属性

Parameters

$attr

Return Value

void

at line 254
struct()

可结构化并返回

at line 298
Column display(Closure $callback)

定义回调

Parameters

Closure $callback

Return Value

Column

at line 307
fillVal($row)

No description

Parameters

$row

Exceptions

Exception

at line 345
$this __call(string $method, array $arguments)

Passes through all unknown calls to builtin renders or supported render.

Allow fluent calls on the Column object.

Parameters

string $method
array $arguments

Return Value

$this

at line 363
string __get(string $key)

获取类属性

Parameters

string $key

Return Value

string

at line 374
static extend($name, $render)

Extend column render.

Parameters

$name
$render

at line 384
static define(string $name, mixed $definition)

定义全局列渲染

Parameters

string $name
mixed $definition

at line 397
Column setRelation(string $relation, string $field, bool $many = false)

设置 Relation

Parameters

string $relation
string $field
bool $many

Return Value

Column

at line 410
protected bool isRelation()

If this column is relation column.

Return Value

bool

at line 420
protected bool hasRenderCallbacks()

If has display callbacks.

Return Value

bool

at line 431
protected mixed callDisplayCallbacks(mixed $value, $row)

调用所有的列渲染回调, 因为 row 可能未自定义的 Query 渲染, 所以返回可能是数组, 这里使用 collect 包裹处理

Parameters

mixed $value
$row

Return Value

mixed

at line 456
protected bool isDefinedColumn()

当前列是否在全局定义中

Return Value

bool

at line 465
protected useDefinedColumn()

使用全局列定义

Exceptions

Exception

at line 499
protected Column resolveRender(string $method, array $arguments)

Find a render to display column.

Parameters

string $method
array $arguments

Return Value

Column

at line 515
protected Column callSupportRender(string $method, array $arguments)

Call Illuminate/Support.

Parameters

string $method
array $arguments

Return Value

Column

at line 538
protected Column callBuiltinRender(string|Closure $abstract, array $arguments)

Call Builtin.

Parameters

string|Closure $abstract
array $arguments

Return Value

Column