PageDescriptor
in package
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
Tags
Table of Contents
- __construct() : PageDescriptor
- Constructor
- addAction() : PageDescriptor
- Add a button with a custom action to this page.
- addActionObject() : PageDescriptor
- Add a button with a custom action to this page.
- addCss() : PageDescriptor
- Adds a custom CSS file to pages.
- addJs() : PageDescriptor
- Adds a custom JS file to pages.
- addLookupColumn() : PageDescriptor
- addSection() : PageDescriptor
- Adds a section (foldable area with a title) to the card page.
- getCss() : array<string|int, mixed>
- getJs() : array<string|int, mixed>
- getLookupsCalculated() : array<string|int, Lookup>
- Gets the Lookup columns and with calculated values.
- getMultipleLookupsCalculated() : array<string|int, mixed>
- Gets the Lookup columns and with calculated values for multiple records
- onAfterCreate() : mixed
- Register event handler. Occours after a record has been inserted into the database.
- onAfterDelete() : mixed
- Register event handler. Occours after a record has been deleted from the database.
- onAfterUpdate() : mixed
- Register event handler. Occours after a record has been updated in the database.
- onBeforeCreate() : mixed
- Register event handler. Occours before a record will be inserted into the database.
- onBeforeDelete() : mixed
- Register event handler. Occours before a record will be deleted from the database.
- onBeforeUpdate() : mixed
- Register event handler. Occours before a record will be updated in the database.
- onOpenCard() : mixed
- Register event handler. Occours before a card page is beeing openend.
- onOpenChart() : mixed
- Register event handler. Occours before a page is beeing openend as a Chart.
- onOpenCreate() : mixed
- Register event handler. Occours before a create page is beeing opened.
- onOpenList() : mixed
- Register event handler. Occours before a list page is beeing opened.
- onOpenUpdate() : mixed
- Register event handler. Occours before a update page is beeing opened.
- setAllowCard() : mixed
- Allow/deny to show records as card page (default = true)
- setAllowChart() : mixed
- Allow/deny to show records as chart (default = true)
- setAllowCreate() : mixed
- Allow/deny to create new records (default = true)
- setAllowDelete() : mixed
- Allow/deny to delete records (default = true)
- setAllowExport() : mixed
- Allow/deny to export records to csv/xml (default = true)
- setAllowUpdate() : mixed
- Allow/deny to update records (default = true)
- setCardLinkColumns() : PageDescriptor
- Defines which columns are shown as link form the list page to the card page.
- setCategory() : mixed
- Name of the category in the menu where this page will be shown
- setConfirmDelete() : mixed
- Show confirmation dialog before deleting a record (default = true)
- setIcon() : mixed
- Fowt Awesome icon name of this page (visible in menu)
- setItemsPerPage() : mixed
- Set number of records per page (overrides the crudkit config value). -1 = use curdkit config
- setMenu() : mixed
- Show in Menu or not
- setSummaryColumns() : PageDescriptor
- Defines which columns are shown in which order on list pages.
- setTitleText() : PageDescriptor
- Defines the title text for specific page types
Methods
__construct()
Constructor
public
__construct(string $name, string $id, TableDescriptor $table[, bool $menu = true ][, string $category = '' ]) : PageDescriptor
Parameters
- $name : string
-
Display name
- $id : string
-
Unique name of the page. Allowed characters: a-z, A-Z, 0-9, "_", "-"
- $table : TableDescriptor
-
Table which is the basis of this page
- $menu : bool = true
-
Show in menu
- $category : string = ''
-
(optional) Name of the category in the menu where this page will be shown
Tags
Return values
PageDescriptor —addAction()
Add a button with a custom action to this page.
public
addAction(string $id, string $label, string $columnLabel, callable $callback[, bool $onList = true ][, bool $onCard = true ][, string $faIcon = '' ][, string $btnClass = '' ][, string $position = '' ][, string $fieldname = '' ][, bool $enabled = true ][, bool $visible = true ][, mixed $data = [] ]) : PageDescriptor
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;
Parameters
- $id : string
-
a identifier for this action (unique per page)
- $label : string
-
Label of the button
- $columnLabel : string
-
Label of the column in list view
- $callback : callable
-
Callback function to execute when pressing the button. This callback has $record, $pageDescriptor, $action(this is what you definde here) as parameters.
- $onList : bool = true
-
(optional) Show on list page
- $onCard : bool = true
-
(optional) Show on card page
- $faIcon : string = ''
-
(optional) Icon for the Button. (Font Awesome icon name)
- $btnClass : string = ''
-
(optional) ''|'default'|'primary'|'info'|'success'|'danger'|'warning'. (Admin LTE Button class)
- $position : string = ''
-
(optional) 'top'|'bottom'|'both'|'before-field'|'after-field'|'to-field'. Position on card pages.
- $fieldname : string = ''
-
(optional) The reference fieldname for $postion ('before-field'|'after-field'|'to-field')
- $enabled : bool = true
-
(optional) If the button is enabled
- $visible : bool = true
-
(optional) If the button is visible
- $data : mixed = []
Tags
Return values
PageDescriptor —addActionObject()
Add a button with a custom action to this page.
public
addActionObject(string $id, Action $action) : PageDescriptor
Parameters
- $id : string
-
a identifier for this action (unique per page)
- $action : Action
-
The Action
Tags
Return values
PageDescriptor —addCss()
Adds a custom CSS file to pages.
public
addCss(string $url[, array<string|int, mixed> $pageTypes = [] ][, bool $isAssetUrl = true ]) : PageDescriptor
Parameters
- $url : string
-
Absolute or relative URL to the CSS file
- $pageTypes : array<string|int, mixed> = []
-
Array of page type names fore the CSS file to add
- $isAssetUrl : bool = true
-
Indicates if its a URL to the Laravel asset directory (/public)
Return values
PageDescriptor —addJs()
Adds a custom JS file to pages.
public
addJs(string $url[, array<string|int, mixed> $pageTypes = [] ][, bool $isAssetUrl = true ]) : PageDescriptor
Hint: when programming in JS you can get data from the global var "curdkit"
Parameters
- $url : string
-
Absolute or relative URL to the JS file
- $pageTypes : array<string|int, mixed> = []
-
Array of page type names fore the JS file to add
- $isAssetUrl : bool = true
-
Indicates if its a URL to the Laravel asset directory (/public)
Return values
PageDescriptor —addLookupColumn()
public
addLookupColumn(string $id, Lookup $lookup) : PageDescriptor
Parameters
- $id : string
-
a identifier for this lookup on the (unique per page)
- $lookup : Lookup
-
The lookup object
Tags
Return values
PageDescriptor —addSection()
Adds a section (foldable area with a title) to the card page.
public
addSection(string $title, string $fromColumnName[, string $toColumnName = '' ][, bool $collapsedByDefault = true ]) : PageDescriptor
Make sure multiple sections do no overlap. Order of from/toColumnName are interchangeable.
Parameters
- $title : string
-
The title to display (unique)
- $fromColumnName : string
- $toColumnName : string = ''
- $collapsedByDefault : bool = true
Return values
PageDescriptor —getCss()
public
getCss() : array<string|int, mixed>
Return values
array<string|int, mixed> —getJs()
public
getJs() : array<string|int, mixed>
Return values
array<string|int, mixed> —getLookupsCalculated()
Gets the Lookup columns and with calculated values.
public
getLookupsCalculated(array<string|int, mixed> $record) : array<string|int, Lookup>
Parameters
- $record : array<string|int, mixed>
Return values
array<string|int, Lookup> —getMultipleLookupsCalculated()
Gets the Lookup columns and with calculated values for multiple records
public
getMultipleLookupsCalculated(array<string|int, mixed> $records) : array<string|int, mixed>
Parameters
- $records : array<string|int, mixed>
Return values
array<string|int, mixed> —onAfterCreate()
Register event handler. Occours after a record has been inserted into the database.
public
onAfterCreate(callable $callback) : mixed
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onAfterCreate($callback);
Parameters
- $callback : callable
Tags
Return values
mixed —onAfterDelete()
Register event handler. Occours after a record has been deleted from the database.
public
onAfterDelete(callable $callback) : mixed
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onAfterDelete($callback);
Parameters
- $callback : callable
-
Callback function which is beeing called if this event occours.
Tags
Return values
mixed —onAfterUpdate()
Register event handler. Occours after a record has been updated in the database.
public
onAfterUpdate(callable $callback) : mixed
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onAfterUpdate($callback);
Parameters
- $callback : callable
Tags
Return values
mixed —onBeforeCreate()
Register event handler. Occours before a record will be inserted into the database.
public
onBeforeCreate(callable $callback) : mixed
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onBeforeCreate($callback);
Parameters
- $callback : callable
Tags
Return values
mixed —onBeforeDelete()
Register event handler. Occours before a record will be deleted from the database.
public
onBeforeDelete(callable $callback) : mixed
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onBeforeDelete($callback);
Parameters
- $callback : callable
Tags
Return values
mixed —onBeforeUpdate()
Register event handler. Occours before a record will be updated in the database.
public
onBeforeUpdate(callable $callback) : mixed
//Reference parametes (&) can be modified inside the function. Very powerfull.
$callback = function(&$pageDescriptor, &$tableDescriptor, &$records){...};
$pageDescriptor->onBeforeUpdate($callback);
Parameters
- $callback : callable
Tags
Return values
mixed —onOpenCard()
Register event handler. Occours before a card page is beeing openend.
public
onOpenCard(callable $callback) : mixed
//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);
Parameters
- $callback : callable
Tags
Return values
mixed —onOpenChart()
Register event handler. Occours before a page is beeing openend as a Chart.
public
onOpenChart(callable $callback) : mixed
//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);
Parameters
- $callback : callable
Tags
Return values
mixed —onOpenCreate()
Register event handler. Occours before a create page is beeing opened.
public
onOpenCreate(callable $callback) : mixed
//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);
Parameters
- $callback : callable
Tags
Return values
mixed —onOpenList()
Register event handler. Occours before a list page is beeing opened.
public
onOpenList(callable $callback) : mixed
//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);
Parameters
- $callback : callable
Tags
Return values
mixed —onOpenUpdate()
Register event handler. Occours before a update page is beeing opened.
public
onOpenUpdate(callable $callback) : mixed
//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);
Parameters
- $callback : callable
Tags
Return values
mixed —setAllowCard()
Allow/deny to show records as card page (default = true)
public
setAllowCard([bool $value = true ]) : mixed
Parameters
- $value : bool = true
Tags
Return values
mixed —setAllowChart()
Allow/deny to show records as chart (default = true)
public
setAllowChart([bool $value = true ]) : mixed
Parameters
- $value : bool = true
Tags
Return values
mixed —setAllowCreate()
Allow/deny to create new records (default = true)
public
setAllowCreate([bool $value = true ]) : mixed
Parameters
- $value : bool = true
Tags
Return values
mixed —setAllowDelete()
Allow/deny to delete records (default = true)
public
setAllowDelete([bool $value = true ]) : mixed
Parameters
- $value : bool = true
Tags
Return values
mixed —setAllowExport()
Allow/deny to export records to csv/xml (default = true)
public
setAllowExport([bool $value = true ]) : mixed
Parameters
- $value : bool = true
Tags
Return values
mixed —setAllowUpdate()
Allow/deny to update records (default = true)
public
setAllowUpdate([bool $value = true ]) : mixed
Parameters
- $value : bool = true
Tags
Return values
mixed —setCardLinkColumns()
Defines which columns are shown as link form the list page to the card page.
public
setCardLinkColumns(array<string|int, string> $cardLinkColumnNames) : PageDescriptor
By the default its the first column of the table´s primary key.
Parameters
- $cardLinkColumnNames : array<string|int, string>
-
Array of column names
Tags
Return values
PageDescriptor —setCategory()
Name of the category in the menu where this page will be shown
public
setCategory([string $value = '' ]) : mixed
Parameters
- $value : string = ''
Tags
Return values
mixed —setConfirmDelete()
Show confirmation dialog before deleting a record (default = true)
public
setConfirmDelete([bool $value = true ]) : mixed
Parameters
- $value : bool = true
Tags
Return values
mixed —setIcon()
Fowt Awesome icon name of this page (visible in menu)
public
setIcon([string $value = '' ]) : mixed
Parameters
- $value : string = ''
Tags
Return values
mixed —setItemsPerPage()
Set number of records per page (overrides the crudkit config value). -1 = use curdkit config
public
setItemsPerPage([int $value = -1 ]) : mixed
Parameters
- $value : int = -1
Tags
Return values
mixed —setMenu()
Show in Menu or not
public
setMenu([bool $value = true ]) : mixed
Parameters
- $value : bool = true
Tags
Return values
mixed —setSummaryColumns()
Defines which columns are shown in which order on list pages.
public
setSummaryColumns(array<string|int, string> $summaryColumnNames) : PageDescriptor
By default all columns are shown in the order they are defined in the table.
Parameters
- $summaryColumnNames : array<string|int, string>
-
Array of column names.
Tags
Return values
PageDescriptor —setTitleText()
Defines the title text for specific page types
public
setTitleText(string $text[, array<string|int, string> $pageTypes = [] ]) : PageDescriptor
$pageDescriptor
->setTitleText('Book'); //For all pages
->setTitleText('New Book', ['create']); //Specific page
Parameters
- $text : string
-
The text to display
- $pageTypes : array<string|int, string> = []
-
(optional) specifies on which page types ('list', 'card', 'create', 'update', 'chart') this text will be shown.