KoolReport's Forum

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

How to set connection explicitly #1598

Open icanstudioz app solutions opened this topic on on Aug 26, 2020 - 1 comments

icanstudioz app solutions commented on Aug 26, 2020

Hi, We use kool report in laravel. And our app is multi tenant. so each domain has their own database. but when working with kool report it always uses central DB not tenant based DB.

Any suggestion to make it work in multi tenant app. We have used this package for tenancy : https://github.com/stancl/tenancy

KoolReport commented on Aug 27, 2020

You can set the connection for report through parameters, for example:

$report = MyReport([
    "tenantDB"=>[
        "connectionString"=> "...",
        "username"=>"...",
        "password"=>"...",
    ]
]);

And in the report class you can do:

class MyReport extends \koolreport\KoolReport
{
    function settings()
    {
        return [
            "dataSources"=>[
                "tenantDB"=>$this=>params["tenantDB"]
            ]
        ];
    }
}

Hope that helps.

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

Laravel