PAGE_TYPES
PAGE_TYPES = array('list', 'card', 'create', 'update', 'chart')
Definition of a webpage (UI).
Examples for usage are provided in the documentation for CrudkitServiceProvider. Important: all methods marked with "@stackable" (like the constructor and all set methods) can be used like this
$page = new PageDesriptor(...)
->setTitleText(...)
->addAction(...)
->...
...easy
$lookups : array<mixed,\Alddesign\Crudkit\Classes\Lookup>
$sections : array<mixed,\Alddesign\Crudkit\Classes\Section>
$actions : array<mixed,\Alddesign\Crudkit\Classes\Action>
__construct(string $name, string $id, \Alddesign\Crudkit\Classes\TableDescriptor $table, boolean $menu = true, string $category = '') : \Alddesign\Crudkit\Classes\PageDescriptor
Constructor
| string | $name | Display name |
| string | $id | Unique name of the page. Allowed characters: a-z, A-Z, 0-9, "_", "-" |
| \Alddesign\Crudkit\Classes\TableDescriptor | $table | Table which is the basis of this page |
| boolean | $menu | Show in menu |
| string | $category | (optional) Name of the category in the menu where this page will be shown |
getActions(\Alddesign\Crudkit\Classes\string $name = '') : \Alddesign\Crudkit\Classes\Action|array<mixed,\Alddesign\Crudkit\Classes\Action>
Retruns on or all actions for this page.
| \Alddesign\Crudkit\Classes\string | $name |
getTable() : \Alddesign\Crudkit\Classes\TableDescriptor
Get the table to this page.
getSummaryColumns(\Alddesign\Crudkit\Classes\bool $namesOnly = false) : array<mixed,string>|array<mixed,\Alddesign\Crudkit\Classes\SQLColumn>
Gets either an array of column names or SqlColumn objects with the list page columns.
| \Alddesign\Crudkit\Classes\bool | $namesOnly |
getCardLinkColumns(\Alddesign\Crudkit\Classes\bool $namesOnly = false) : array<mixed,string>|array<mixed,\Alddesign\Crudkit\Classes\SQLColumn>
Gets either an array of column names or SqlColumn objects with the card link columns.
| \Alddesign\Crudkit\Classes\bool | $namesOnly |
getLookupsCalculated(array $record) : array<mixed,\Alddesign\Crudkit\Classes\Lookup>
Gets the Lookup columns and with calculated values.
| array | $record |
setSummaryColumns(array<mixed,string> $summaryColumnNames) : \Alddesign\Crudkit\Classes\PageDescriptor
Defines which columns are shown in which order on list pages (defaul = all, order = as defined in tables).
| array<mixed,string> | $summaryColumnNames |
setCardLinkColumns(array<mixed,string> $cardLinkColumnNames) : \Alddesign\Crudkit\Classes\PageDescriptor
Defines which columns are shown as link form list to card page (defaul = first column of Tables PK)
$pageDescriptor->setCardLinkColumns(["id", "name"]);
| array<mixed,string> | $cardLinkColumnNames |
setTitleText(string $text, array<mixed,string> $pageTypes = array()) : \Alddesign\Crudkit\Classes\PageDescriptor
Defines the title text for specific page types
$pageDescriptor
->setTitleText('Book'); //For all pages
->setTitleText('New Book', ['create']); //Specific page
| string | $text | The text to display |
| array<mixed,string> | $pageTypes | (optional) specifies on which page types ('list', 'card', 'create', 'update', 'chart') this text will be shown. |
addLookupColumn(string $id, \Alddesign\Crudkit\Classes\Lookup $lookup) : \Alddesign\Crudkit\Classes\PageDescriptor
| string | $id | a identifier for this lookup on the (unique per page) |
| \Alddesign\Crudkit\Classes\Lookup | $lookup | The lookup object |
addAction(string $id, string $label, string $columnLabel, callable $callback, boolean $onList = true, boolean $onCard = true, string $faIcon = '', string $btnClass = '', string $position = '', string $fieldname = '', boolean $enabled = true, boolean $visible = true, $data = array()) : \Alddesign\Crudkit\Classes\PageDescriptor
Add a button with a custom action to this page.
Be creative, but take care. Your can write you own php code and use all of crudkits api to manipulate data, etc... (see apidoc-dev):
$callback = function($record, $pageDescriptor, $action) { mail('ceo@mydomain.com', 'Book info', 'Check out our new book: '. $record["name"]); };
$pageDescriptor->addAction('mail', 'Send book-info mail', 'Mail', $callback, true, true, envelope, 'info');
//Next thing: drop table studends;
| string | $id | a identifier for this action (unique per page) |
| string | $label | Label of the button |
| string | $columnLabel | Label of the column in list view |
| callable | $callback | Callback function to execute when pressing the button. This callback has $record, $pageDescriptor, $action(this is what you definde here) as parameters. |
| boolean | $onList | (optional) Show on list page |
| boolean | $onCard | (optional) Show on card page |
| string | $faIcon | (optional) Icon for the Button. (Font Awesome icon name) |
| string | $btnClass | (optional) ''|'default'|'primary'|'info'|'success'|'danger'|'warning'. (Admin LTE Button class) |
| string | $position | (optional) 'top'|'bottom'|'both'|'before-field'|'after-field'|'to-field'. Position on card pages. |
| string | $fieldname | (optional) The reference fieldname for $postion ('before-field'|'after-field'|'to-field') |
| boolean | $enabled | (optional) If the button is enabled |
| boolean | $visible | (optional) If the button is visible |
| $data |
addActionObject(string $id, \Alddesign\Crudkit\Classes\Action $action) : \Alddesign\Crudkit\Classes\PageDescriptor
Add a button with a custom action to this page.
| string | $id | a identifier for this action (unique per page) |
| \Alddesign\Crudkit\Classes\Action | $action | The Action |
addSection(string $title, string $fromColumnName, string $toColumnName = '', boolean $collapsedByDefault = true) : \Alddesign\Crudkit\Classes\PageDescriptor
Adds a section (foldable area with a title) to the card page.
Make sure multiple sections do no overlap. Order of from/toColumnName are interchangeable.
| string | $title | The title to display (unique) |
| string | $fromColumnName | |
| string | $toColumnName | |
| boolean | $collapsedByDefault |
addJs(string $url, array $pageTypes = array(), boolean $isAssetUrl = true) : \Alddesign\Crudkit\Classes\PageDescriptor
Adds a custom JS file to pages.
Hint: when programming in JS you can get data from the global var "curdkit"
| string | $url | Absolute or relative URL to the JS file |
| array | $pageTypes | Array of page type names fore the JS file to add |
| boolean | $isAssetUrl | Indicates if its a URL to the Laravel asset directory (/public) |
addCss(string $url, array $pageTypes = array(), boolean $isAssetUrl = true) : \Alddesign\Crudkit\Classes\PageDescriptor
Adds a custom CSS file to pages.
| string | $url | Absolute or relative URL to the CSS file |
| array | $pageTypes | Array of page type names fore the CSS file to add |
| boolean | $isAssetUrl | Indicates if its a URL to the Laravel asset directory (/public) |
onOpenList(callable $callback)
Register event handler. Occours before a list page is beeing opened.
//Reference parametes (&) can be modified inside the function. Very powerfull.
//$viewData is an array with all the data sent to the view. Too much to explain. $viewData['records'] for example is interesting
$callback = function(&$pageDescriptor, &$tableDescriptor, &$viewData){...};
$pageDescriptor->onOpenList($callback);
| callable | $callback |
onOpenCard(callable $callback)
Register event handler. Occours before a card page is beeing openend.
//Reference parametes (&) can be modified inside the function. Very powerfull.
//$viewData is an array with all the data sent to the view. Too much to explain. $viewData['record'] for example is interesting
$callback = function(&$pageDescriptor, &$tableDescriptor, &$viewData){...};
$pageDescriptor->onOpenCard($callback);
| callable | $callback |
onOpenCreate(callable $callback)
Register event handler. Occours before a create page is beeing opened.
//Reference parametes (&) can be modified inside the function. Very powerfull.
//$viewData is an array with all the data sent to the view. Too much to explain. $viewData['record'] for example is interesting
$callback = function(&$pageDescriptor, &$tableDescriptor, &$viewData){...};
$pageDescriptor->onOpenCreate($callback);
| callable | $callback |
onOpenUpdate(callable $callback)
Register event handler. Occours before a update page is beeing opened.
//Reference parametes (&) can be modified inside the function. Very powerfull.
//$viewData is an array with all the data sent to the view. Too much to explain. $viewData['record'] for example is interesting
$callback = function(&$pageDescriptor, &$tableDescriptor, &$viewData){...};
$pageDescriptor->onOpenUpdate($callback);
| callable | $callback |
onOpenChart(callable $callback)
Register event handler. Occours before a page is beeing openend as a Chart.
//Reference parametes (&) can be modified inside the function. Very powerfull.
//$viewData is an array with all the data sent to the view. Too much to explain. $viewData['record'] for example is interesting
$callback = function(&$pageDescriptor, &$tableDescriptor, &$viewData){...};
$pageDescriptor->onOpenChart($callback);
| callable | $callback |
onBeforeCreate(callable $callback)
Register event handler. Occours before a record will be inserted into the database.
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onBeforeCreate($callback);
| callable | $callback |
onAfterCreate(callable $callback)
Register event handler. Occours after a record has been inserted into the database.
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onAfterCreate($callback);
| callable | $callback |
onBeforeUpdate(callable $callback)
Register event handler. Occours before a record will be updated in the database.
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onBeforeUpdate($callback);
| callable | $callback |
onAfterUpdate(callable $callback)
Register event handler. Occours after a record has been updated in the database.
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onAfterUpdate($callback);
| callable | $callback |
onBeforeDelete(callable $callback)
Register event handler. Occours before a record will be deleted from the database.
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onBeforeDelete($callback);
| callable | $callback |
onAfterDelete(callable $callback)
Register event handler. Occours after a record has been deleted from the database.
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onAfterDelete($callback);
| callable | $callback | Callback function which is beeing called if this event occours. |