Hello
According to laravel koolreport, I have placed my reports folder inside the app folder. Created a new ReportController. Also a report.blade.php inside the views. Everything is working fine. But only with html and css . When there is only html it output the pdf content. But when i tried to add code for table or Barchart it return me a blank pdf.
Exportable package is also there. Also made use of assets inside setting function but nothing works.
Here is my code
This is my MyReport.view.php file
<?php
use \koolreport\widgets\google\BarChart;
$category_amount = 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),
);
?>
Code for bar chart
<?php
BarChart::create(array(
"title"=>"Sale Report",
"dataStore"=>$category_amount,
"columns"=>array(
"category"=>array("label"=>"category"),
"sale"=>array("label"=>"Sale","type"=>"number","prefix"=>"$"),
"cost"=>array("label"=>"Cost","type"=>"number","prefix"=>"$"),
"profit"=>array("label"=>"Profit","type"=>"number","prefix"=>"$"),
)
));
?>
This is my report.blade.php
<?php
$report->render();
?>
And this is my ReportController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Reports\MyReport;
use View;
use \koolreport\instant\Widget;
use \koolreport\chartjs\ColumnChart;
class ReportController extends Controller{
public function __construct(){
$this->middleware("guest");
}
public function index(Request $request){
$report = new MyReport();
$report->export()
->settings(array(
"resourceWaiting"=>5000,
))
->pdf(array(
"format"=>"A4",
"orientation"=>"portrait"
))
->toBrowser("report.pdf");
}
}