KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

How to use data as Array in setup() ? #712

Closed Frank TheDoor opened this topic on on Feb 26, 2019 - 1 comments

Frank TheDoor commented on Feb 26, 2019

I use laravel and prefer to build the data myself (with eloquent Models) rather than retrieve the query and ask the report to build it.

I am confused about dataSource/dataSources/dataStore property/method. How can I add the Array to the report class in the setup method. I expect something similar to:

  function setup()
  {
    $data = Device::where('customer','1')->get()->toArray();
    $this->dataSources('billable', $data); 
//or maybe
    $this->dataStore('billable')->pipe($data);
  }

I have seen the following in a report.view.php sample, but would like to pass the $data to the report.view.php from the class, not write it directly in the view:

$data = array(
  array("category"=>"Books","sale"=>32000,"cost"=>20000,"profit"=>12000),
);
Table::create(array(
  "dataSource"=>$data
));

Thx

Frank TheDoor commented on Feb 26, 2019

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None