Traits

TName #

TName trait allows object to get or set name with name() method. The Dashboard and Widget are implemented this trait.

Example:

class MyClass
{
    use \koolreport\dashboard\TName;
}

$obj = new MyClass();
echo $obj->name();
// Output "MyClass"

$obj->name("this is my class");
echo $obj->name();
//Output "this is my class"

TAppLink trait contains app() function which allows get/set the application object. Dashboard, Widget, Request are implemented this trait.

Example:

$this->app(); //Get the app object

$this->app($app); //Set the app object

TDashboardLink trait contains dashboard() function which allows get/set the dashboard object. Widget is implemented this trait.

Example:

$this->dashboard(); //Get the dashboard object

$this->dashboard($dashboard); //Set the dashboard object

TWidgetLink trait contains widget() function which allows get/set the widget object. Field is implemented this trait.

Example:

$this->widget(); //Get the widget object

$this->widget($widget); //Set the dashboard object

TParams #

TParams provides params() method to object. Dashboard and Widget are implemented this trait.

Example:

//Set parameters
$this->params([
    "year"=>2020,
    "productId"=>30
]);

$this->params(); //Get all params

$this->params("year"); // Get only year parameter

TEnabledPermit #

TEnabledPermit provides methods enabled() and enabledWhen() method to object. Dashboard, Widget and Field are implemented this trait.

enabled() #

Get or set the availability of object

Example:

$this->enabled(false); // Disable the object

// Set by function
$this->enabled(function($request) {
    return $request->user()->hasRole("admin");
});

// Get status
$enabled = $this->enabled();

enabledWhen() #

If your application is provided with Permit object then you can use enabledWhen()

Example:

$this->enabledWhen("beAdmin");

//The "beAdmin" is define like this

class Permit extends \koolreport\dashboard\Permit
{
    protected function beAdmin($request, $sender)
    {
        return $request->user()->hasRole("admin");
    }
}

//The Permit will be provided to Application like this:

class App extends \koolreport\dashboard\Application
{
    protected function permission()
    {
        return Permit::create();
    }
}

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.