class Link extends TableColumn (View source)

Properties

protected Closure|null $url
protected Closure|string|null $content
protected bool $targetBlank

Methods

__construct(string|null $key = null, string|null $field = null, string|null $title = null, string|null $sortKey = null, bool $sortable = false, bool $defaultSort = false, string $defaultSortDirection = 'ASC', bool $optional = false, bool $linkToEdit = false, bool $visible = true, bool $html = false, Closure|string|null $link = null, Closure|null $render = null, Closure|null $sortFunction = null, string|null $specificType = null, bool $shrink = false)

No description

static TableColumn
make()

No description

string
getKey()

No description

shrink(bool $shrink = true)

No description

field(string $field)

Set the field name to be used for this column. This is the field that will be used to query the database.

string
getField()

No description

title(string|null $title)

Sets the title of the column.

sortable(bool $sortable = true)

When enabled the column is sortable by clicking on the header.

sortByDefault(bool $defaultSort = true, string $direction = 'ASC')

When enabled this will be the default column the list is sorted by.

bool
isDefaultSort()

No description

string
getDefaultSortDirection()

No description

optional(bool $optional = true)

Makes the column optional, when set it can be hidden using the gear icon above the listing.

hide(bool $visible = false)

To be used with ->optional, but it will be hidden by default.

renderHtml(bool $html = true)

When enabled the content will be rendered as html.

linkCell(Closure|string $link)

Links the column content to a fixed url or url via the closure.

linkToEdit(bool $linkToEdit = true)

No description

bool
shouldLinkToEdit()

No description

sortKey(string|null $sortKey)

A separate sortKey if different from the field name.

string
getSortKey()

No description

order(Closure $sortFunction)

An optional closure accepting the QueryBuilder and sort direction to apply when this field is being sorted.

Closure|null
getOrderFunction()

No description

customRender(Closure $renderFunction)

Set a custom render function that will receive the model as its function argument.

array
toColumnArray(array $visibleColumns = [], bool $sortable = true)

No description

string
renderCell(TwillModelContract $model)

No description

int|bool|string
getRenderValue(TwillModelContract $model)

No description

url(Closure $urlFunction)

No description

content(Closure|string $contentFunction)

No description

shouldOpenInNewWindow(bool $shouldOpenInNewWindow = true)

No description

Details

final protected __construct(string|null $key = null, string|null $field = null, string|null $title = null, string|null $sortKey = null, bool $sortable = false, bool $defaultSort = false, string $defaultSortDirection = 'ASC', bool $optional = false, bool $linkToEdit = false, bool $visible = true, bool $html = false, Closure|string|null $link = null, Closure|null $render = null, Closure|null $sortFunction = null, string|null $specificType = null, bool $shrink = false)

No description

Parameters

string|null $key
string|null $field
string|null $title
string|null $sortKey
bool $sortable
bool $defaultSort
string $defaultSortDirection
bool $optional
bool $linkToEdit
bool $visible
bool $html
Closure|string|null $link
Closure|null $render
Closure|null $sortFunction
string|null $specificType
bool $shrink

static TableColumn make()

No description

Return Value

TableColumn

string getKey()

No description

Return Value

string

TableColumn shrink(bool $shrink = true)

No description

Parameters

bool $shrink

Return Value

TableColumn

TableColumn field(string $field)

Set the field name to be used for this column. This is the field that will be used to query the database.

If no title is set, it will also update the title.

Parameters

string $field

Return Value

TableColumn

string getField()

No description

Return Value

string

TableColumn title(string|null $title)

Sets the title of the column.

Parameters

string|null $title

Return Value

TableColumn

TableColumn sortable(bool $sortable = true)

When enabled the column is sortable by clicking on the header.

Parameters

bool $sortable

Return Value

TableColumn

TableColumn sortByDefault(bool $defaultSort = true, string $direction = 'ASC')

When enabled this will be the default column the list is sorted by.

Parameters

bool $defaultSort
string $direction

Return Value

TableColumn

bool isDefaultSort()

No description

Return Value

bool

string getDefaultSortDirection()

No description

Return Value

string

TableColumn optional(bool $optional = true)

Makes the column optional, when set it can be hidden using the gear icon above the listing.

Parameters

bool $optional

Return Value

TableColumn

TableColumn hide(bool $visible = false)

To be used with ->optional, but it will be hidden by default.

Parameters

bool $visible

Return Value

TableColumn

TableColumn renderHtml(bool $html = true)

When enabled the content will be rendered as html.

Parameters

bool $html

Return Value

TableColumn

TableColumn linkCell(Closure|string $link)

Links the column content to a fixed url or url via the closure.

Parameters

Closure|string $link

Return Value

TableColumn

TableColumn linkToEdit(bool $linkToEdit = true)

No description

Parameters

bool $linkToEdit

Return Value

TableColumn

bool shouldLinkToEdit()

No description

Return Value

bool

TableColumn sortKey(string|null $sortKey)

A separate sortKey if different from the field name.

Parameters

string|null $sortKey

Return Value

TableColumn

string getSortKey()

No description

Return Value

string

TableColumn order(Closure $sortFunction)

An optional closure accepting the QueryBuilder and sort direction to apply when this field is being sorted.

If you are using the Relation field, this sort is required to make it work. Please note that when you are having a belongsToMany you have to carefully write your join because otherwise you may end up with duplicate rows.

Parameters

Closure $sortFunction

Return Value

TableColumn

Closure|null getOrderFunction()

No description

Return Value

Closure|null

TableColumn customRender(Closure $renderFunction)

Set a custom render function that will receive the model as its function argument.

You can use this to display for example a view or formatted date.

Parameters

Closure $renderFunction

Return Value

TableColumn

array toColumnArray(array $visibleColumns = [], bool $sortable = true)

No description

Parameters

array $visibleColumns
bool $sortable

Return Value

array

string renderCell(TwillModelContract $model)

No description

Parameters

TwillModelContract $model

Return Value

string

protected int|bool|string getRenderValue(TwillModelContract $model)

No description

Parameters

TwillModelContract $model

Return Value

int|bool|string

Link url(Closure $urlFunction)

No description

Parameters

Closure $urlFunction

Return Value

Link

Link content(Closure|string $contentFunction)

No description

Parameters

Closure|string $contentFunction

Return Value

Link

Link shouldOpenInNewWindow(bool $shouldOpenInNewWindow = true)

No description

Parameters

bool $shouldOpenInNewWindow

Return Value

Link