Admin Panel

Overview #

Admin Panel is a beautiful administration dashboard. Admin Panel is a special part of Dashboard Framework which is built on top of KoolReport Pro. Features-rich, low-code orientation yet high customization are all we describe about Admin Panel.

Features #

FeaturesDescription
Data ManagementAdmin Panel by default provides a full functional CRUD to let you manage your data with data listing, detail view, data updating and deleting.
Different Data ViewsAdmin Panel by default provides a full functional CRUD to let you manage your data with data listing, detail view, data updating and deleting.
Multi-variable Data FiltersSearching for data based on condition is a basic and a must in any application, Admin Panel provide you a simple way to filter your data on any variables.
Customizable Actions on DataAdmin Panel allows you to write custom action that took place on a single instance of resource or a group of resource.
Built with AuthorizationWritten on top of Dashboard Framework, Admin Panel inherits the power of authorization. Every action, every features of admin panel can be switched on/off based on user's permissions.
Highly customizableBuilt with low-code orientation but Admin Panel does not loose its flexibility and customizability. Every part of Admin Panel can be customized and overwritten with new functionality or new interface.

Installation #

Admin Panel is a feature of Dashboard Framework but because of its size in functionality, we break it into separate section. To install Admin Panel, you just need to install Dashboard Framework.

Install Dashboard Framework

Quick Start #

Create bootstrap file #

We will create an index file that will initiate the application.

<?php

//index.php

require_once "vendor/autoload.php";
require_once "App.php";

App::create()->debugMode(true)->run();

Create Application #

We create an App with registered CustomerResource inside dashboards() methods.

<?php
//App.php

use \koolreport\dashboard\Application;

class App extends Application
{
    protected function sidebar()
    {
        return [
            "Customers"=>CustomerResource::create()
        ];
    }
}

Create your resource #

We create CustomerResource which is a class to manage table customers in database.

<?php
//CustomerResource.php

use \koolreport\dashboard\admin\Resource;
use \koolreport\dashboard\fields\ID;
use \koolreport\dashboard\fields\Text;

class CustomerResource extends Resource
{
    protected function onCreated()
    {
        $this->manageTable("customers")->inSource(AutoMaker::class);
    }

    protected function fields()
    {
        return [
            ID::create("customerNumber"),
            Text::create("customerName"),
        ];
    }
}

Create your database source #

We define the last missing piece which is the AutoMaker data source.

<?php
//AutoMaker.php
use \koolreport\dashboard\sources\MySQL;

class AutoMaker extends MySQL
{
    protected function connection()
    {
        return [
            "connectionString"=>"mysql:host=sampledb.koolreport.com;dbname=dbautomaker_edit",
            "username"=>"expusr",
            "password"=>"koolreport sampledb",
            "charset"=>"utf8"
        ];
    }
}

All done! #

With above little source-code you will have a full functional CRUD to manage your customers table.

Download source-code admin-panel-quickstart.zip

The basics #

Resources #

The Resource is an entrant of admin panel in which we define the table in database that resource will manage.

More about Resource.

Fields #

We can define list of important fields that will be used in a Resource or a view of resource (a.k.a Glass)

protected function fields()
{
    return [
        ID::create("customerNumber"),
        Text::create("customerName"),
        Date::create("joinedDate"),
    ];
}

More about Fields.

Filters #

In Resource or Glass class, we can provide a list of Filters that will be shown on top-right of admin table to provide ability to do multi-variable filtering job.

protected function filters()
{
    return [
        CountrySelectFilter::create(),
        AgeRangeFilter::create(),
    ];
}

More about Filters.

Glasses #

Glass define another different view of Resource. For example, we want to view the most valued customers out of our customer list. The Glass allows us to customize the query, list of fields appeared on admin table or the filters and actions applied to data. We will provide list of glasses into Resource class like following

protected function glasses()
{
    return [
        MostValuedCustomers::create(),
        FrequentCustomers::create(),
    ];
}

More about Glasses.

Actions #

Action define an action that application's user can take upon an instance of resource or multi-instance of resources. We can provide list of actions in Resource or in Glass like following:

protected function actions()
{
    return [
        UpdateAction::create(),
        DeleteAction::create(),
        EmailAction::create(),
    ];
}

More about Actions.

Relations #

Relations is the link between Resources just like the link between tables in database. The relations of one Resource to others will be specified in relations() method.

class Order extends Resource
{
    ...
    protected function relations()
    {
        return [
            BelongsTo::resource(Customer::class)
                ->link(["customerNumber"=>"customerNumber"]),

            HasMany::resource(Product::class)
                ->link(["productCode"=>"productCode"])
        ];
    }
}

More about Resources.

Highlights #

Highlights is a group of widgets showing on top of Resource, Glass or detail view of an resource instance. You can put any dashboard's widgets like charts, metrics into highlights:

protected function highlights()
{
    return [
        TotalCustomerMetric::create(),
        CustomerByPaymentMethod::create(),
        CustomerTrend::create(),
    ];
}

More about Highlights.

Bottom #

While highlights allow you to put any widgets on top, the bottom allow you to put anything at the bottom of page. So you just need to create the bottom() method and return list of widgets in array form:

protected function bottom()
{
    return [
        Html::div("Any content")
    ];
}

More about Bottom

The advances #

Permissions #

Permission is a crucial part in any system and Admin Panel is not an exception. In Admin Panel, each and every elements can be made available or not available for specific user or user group. Please visit Permission to learn about authorization in Resource, Fields, Actions and all other elements.

Learn more about Permission.

Customization #

Any elements in admin panel interface can be changed its settings. The elements are organized in a tree that you can easily access.

Learn more about Screens.

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.