Laravel Framework

Overview #

KoolReport works great with Laravel Framework like any other PHP MVC Framework.

Load library #

Depend on how do you install KoolReport with Laravel Framework. If you install with composer then you do not need to do anything, just start your reference to KoolReport because KoolReport's library will be automatically loaded together with Laravel Framework. But if you install manually by downloading and copying into your web apps. make sure you require the KoolReport like this:

require_once "/path/to/koolreport/autoload.php";

Use any widgets #

You can use any KoolReport's widgets inside Laravel views:

index.blade.php

<?php
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\widgets\google\ColumnChart;

    $data = array(
        array("category"=>"Books","sale"=>32000,"cost"=>20000,"profit"=>12000),
        array("category"=>"Accessories","sale"=>43000,"cost"=>36000,"profit"=>7000),
        array("category"=>"Phones","sale"=>54000,"cost"=>39000,"profit"=>15000),
        array("category"=>"Movies","sale"=>23000,"cost"=>18000,"profit"=>5000),
        array("category"=>"Others","sale"=>12000,"cost"=>6000,"profit"=>6000)
    );
?>
<html>
    <head>
        <title>KoolReport's Widgets</title>
    </head>
    <body>
    <body>
        <?php 
        Table::create(array(
            "dataSource"=>$data
        ));
        ?>
        <?php 
        ColumnChart::create(array(
            "dataSource"=>$data
        ));
        ?>
    </body>
</html>

With Laravel DB #

<?php
    use \koolreport\widgets\google\ColumnChart;
?>
<html>
    <head>
        <title>KoolReport's Widgets</title>
    </head>
    <body>
    <body>
        <?php 
        ColumnChart::create(array(
            "dataSource"=>DB::table('orders')
                            ->select('department', DB::raw('SUM(price) as total_sales'))
                            ->groupBy('department')
                            ->havingRaw('SUM(price) > ?', [2500])
                            ->get()
        ));
        ?>
    </body>
</html>

It is cool, isn't it! Actually you can feed any Collection of Laravel to the "dataSource" of KoolReport's widget to get them visualize. KoolReport's widget now does not stick themselves inside environment of KoolReport's view. We hope that you may find it useful for any of your project.