PHP code example of asignua / filament-scheduled-reports

1. Go to this page and download the library: Download asignua/filament-scheduled-reports library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

asignua / filament-scheduled-reports example snippets


use Asignua\FilamentScheduledReports\ScheduledReportsPlugin;

$panel->plugin(
    ScheduledReportsPlugin::make()
        // Whom the owner may add besides themselves: id => label. Default: nobody, only the owner.
        ->recipients(fn (User $owner): array => $owner->team->users()->pluck('name', 'id')->all())
);

use Asignua\FilamentScheduledReports\Actions\ScheduleReportAction;

protected function getHeaderActions(): array
{
    return [XlsxExportAction::make(), ScheduleReportAction::make()];
}

Gate::define('scheduleReport', fn (User $user, ?string $page = null) => $user->can('reports.schedule')); // $page: the page class
Gate::define('manageScheduledReports', fn (User $user) => $user->isAdmin());                              // see and pause everybody's

use Filament\Panel;
use Illuminate\Contracts\Auth\Authenticatable;

ScheduledReportsPlugin::make()
    ->beforeRun(function (Authenticatable $owner, Panel $panel, ScheduledReport $report): void {
        // Re-apply here what your panel middleware / bootUsing() sets for a browser request, from $owner.
        app(CurrentBranch::class)->set($owner->branch_id);
    })
    ->

ScheduledReportsPlugin::make()
    ->allowExternalRecipients()
    ->allowedDomains(['example.com']); // exact match; a subdomain is another domain; no domains = nobody