Glasses
Overview #
Glass defines a different view to your original data. In a Glass, you can alternate the list of actions or filters appeared on the glasses.
Define glass #
<?php
use koolreport\dashboard\admin\glasses\Glass;
class MyGlass extends Glass
{
protected function onCreated()
{
$this
->title("Glass Title")
->icon("fa fa-user");
}
protected function query($query)
{
//Apply change to query or make a new query
//Return query
return $query;
}
protected function fields()
{
return [
ID::create("id-column"),
Text::create("text-field"),
];
}
}
Properties #
Name | type | default | description |
---|---|---|---|
title | string | Title of the glass | |
icon | string | Icon to be shown for this glass | |
type | string | "secondary" | Accept "primary","secondary", "success", "info", "warning", "danger" |
Query #
Glass provides you a query()
method in which you receive the original query of the Resource as parameter. You can use that original query and alternate it or you can write a completely new query. The most important is you will return the query in the method. Your new query will be used to build the view of glass.
If you do not override the query() method, the original query will be used.
Fields #
Glass provides you fields()
methods in which you can enter the list of fields to display. The fields should be matched with your query inside query()
.
protected function fields()
{
return [
ID::create("id-column"),
...
];
}
If you do not override fields()
methods, the list of fields in Resource will be used.
Filters #
Glass provides you the filters()
function to let you alternate the list of filters in the glass.
protected function filters()
{
return [
CountryFilter::create(),
...
];
}
If you do not override this methods, then the list of filters defined in Resource will be used.
Actions #
Glass also provides the actions()
method which you can override to provide list of actions only available in this glass.
protected function actions()
{
return [
EmailAction::create(),
...
];
}
If you do not override then the actions defined in Resource will be used.
Highlights #
Glass also let you customize the highlights appear on top of admin table. By override the highlights()
method then you can provide a new list of widgets to be highlighted.
protected function highlights()
{
return [
CustomerPaymentMetric::create(),
...
];
}
Register glass #
To register a glass into Resource, you provide list of glasses into glasses()
method:
class MyResource extends Resource
{
protected function glasses()
{
return [
MyGlass::create(),
...
];
}
}
The list of glasses will be appear on top-left of your admin table.
Get started with KoolReport
KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.