KoolReport's Forum

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

Export Report from Laravel Scheduler #3139

Open Charlie May opened this topic on on Sep 6, 2023 - 2 comments

Charlie May commented on Sep 6, 2023

Hello, I have a request from a customer of mine to setup automated reporting that is emailed to a specific group of users that they define. I have the report built and can view on the web and manually export.

From what I can tell the export feature requires a web request to be made via POST. The issue I have is that since this is a multi tenant application I don't have an authenticated user while running the report instead use a method from the tenancy class that loops through the tenants and initializes tenancy.

Is there a different way to build the base64 version of a PDF without forcing a POST request?

I did try this to auth the post request but still runs outside of that scope.


<?php
Auth::login($user);
$this->info(tenant());
$this->info(auth()->user());
//'http://' . $tenant->primary_domain->domain . '.pm3.test/reports/compliance'
$response = Http::asForm()->post($tenant->route('tenant.reports.compliance'), [
    '_token' => csrf_token(),
     'dateRange' => [now()->subDay()->timezone('America/Los_Angeles'), now()->addDays(90)->timezone('America/Los_Angeles')],
                            ]);
$this->info($response->body());
Sebastian Morales commented on Sep 7, 2023

So far the Export package needs a get/post request sent to the report url/route to perform export task. Since your reports require user authentication to view and export, if you want to export on scheduling you would need to authenticate via an API. For example using:

https://laravel.com/docs/10.x/passport

Anyway, we realize this is not convenient for users of KoolReport. We will find a solution so that users could export by executing a script without sending a request.

Charlie May commented on Sep 7, 2023

I appreciate the reply. Unfortunately that is a lot of extra complexity for a simple feature such as a report. I'll see if I can just write a manual report class and build out the base64 return for now.

Hopefully a solution within the export package will get added in the future :)

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

Export