Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
KoolReport can be used in Laravel or any MVC frameworks. You create report from KoolReport normally as you do. Then to start the report in Laravel you do:
Route::get('/testreport', function(){
$report = new SaleReport;
$report->run();
return view('testreport',["report"=>$report]);
});
At the view of Laravel:
<div>
<?php $report->render(); ?>
</div>
Let me know if you need further assistance.
Here is the step to setup KoolReport in Laravel:
Step 1 Download KoolReport
Step 2 Unzip and copy koolreport
folder into vendor
folder under your laravel project.
Step 3 In folder app, create folder name "Reports"
Step 4 Create MyReport.php
and MyReport.view.php
with following content:
<?php
//MyReport.php
namespace App\Reports;
require_once dirname(__FILE__)."/../../vendor/koolreport/autoload.php";
class MyReport extends \koolreport\KoolReport
{
//We leave this blank to demo only
}
<!-- MyReport.view.php -->
<html>
<head>
<title>My Report</title>
</head>
<body>
<h1>It works</h1>
</body>
</html>
Step 5 In your folder app/Http/Controllers
create ReportController.php
with following content:
<?php
// ReportController.php
namespace App\Http\Controllers;
use App\Reports\MyReport;
class ReportController extends Controller
{
public function __contruct()
{
$this->middleware("guest");
}
public function index()
{
$report = new MyReport;
$report->run();
return view("report",["report"=>$report]);
}
}
Step 6 In the resources/view
, you add report.blade.php
with following content:
<?php echo $report->render(); ?>
Step 7 In your routes/web.php
, you add the route to ReportController@index
Route::get('/report', "ReportController@index");
All done! Now if you go to "http://localhost/yourlaravelproject/public/report", you will see the page "It works" meaning that KoolReport has been running.
i have a report.php class with method1 and has view file report.view.php but now i need to make method2 in same class but which view file i will use and how to call like report1.view.php please help
<?php
//MyReport.php
namespace App\Reports;
require_once dirname(__FILE__)."/../../vendor/koolreport/autoload.php";
class MyReport extends \koolreport\KoolReport
{
function method1(){
report.view.php /// how view file call by name
}
function method2(){
report1.view.php /// how view file call by name
}
}
Fahad,
KoolReport does not have separate methods in controller so basically you create another report. For example you may have SaleReport.php, CustomerReport.php.. each report has its own data connection, processing and visualization. If you need to use the same data connection for all report. You may create a BaseReport.php in which you have your connection in setup() function and all other reports will derive from it. If you use the \koolreport\laravel\Friendship
then your report can use Laravel database directly, you may not need the BaseReport like I suggested.
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo