-
Notifications
You must be signed in to change notification settings - Fork 0
Home
plokko edited this page Nov 29, 2021
·
5 revisions
A Laravel heper ( based on plokko/resource-query ) for creating dynamic (orderable and fiterable) AJAX tables.
Install throught composer composer require plokko/querable-resource
...
- formAction(string $action) - Set the form action, defaults to ''
- column(string $name) - Declares or retrieve a column by name
- removeColumn(string $name) - Removes a column by name
- setDefaultSortBy(array $attr) - Array of default sorting order (Ex. ['field1',['field2','desc'],]
- setBaseLangFile(string $attr) - Set the translation file for label, the file (or field) should contain an array with field name as key and labels as values
- selectFields(array|null $fields) - Explicitly set selected fields (ex. ['id',DB::raw('count(id)'),...])
- autoSelect(boolean $enabled) - Enables or disable auto select field generation
- render() - Returns the table (render in view)
- renderAttr() - Returns the table attributes (render in view)
- renderBody() - Returns the table body (render in view)
- getHeaders() - Returns the headers as an array
Column fields are set by calling a function with the value:
- label(string|null $value) - Text to use in the headers, if none is specified it will be used the label from global translations or field name
- field(string|null|\Illuminate\Database\Query\Expression $value) - Set the table field used for select (and filtering or sorting if not explicit), defaults to table name if not set.
- type(string|null type) - Set field type (ex. boolean, email, etc.) for formatting
- align(string|null type) - Set header alignment (left|center|right)
- component(string|null $component) - Set field component (in render)
- rowClass(string|null $class) - Set row (CSS) class
- cellClass(string|null $class) - Set cell (CSS) class
- visible(bool $visible) - Sets the column visibility
- virtual(bool $virtual) - Sets the column as virtual (no corresponding table field, ex. table actions)
- columnView(null|string|\Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|Closure $view) - Sets the column view
- virtual(bool $virtual) - Sets the column as virtua (no corresponding table field, ex. table actions)
- attr(string $key,mixed $value) - Set one field attribute as key-value
- setAttrs(array $attributes) - Set all attributes as a key-value array
- sort(boolean|null|string|\Illuminate\Database\Query\Expression $field,[boolean $reverse]) - Makes the column sortable, first argument is table field (null or false to disable sorting, true to use base field or string or Expression to specify sorted field). If $reverse is set to true the sorting will be reversed (asc. when desc and vice versa)
- filter(string|boolean|Closure $condition='=',null|string|\Illuminate\Database\Query\Expression $field=null) - Makes the column filterable, $condition specifies the condition to use and $field specifies the field to use (defaults to base field if null)
- remove() - Alias of removeColumn('<column-name>'), removes the column