pxlrbt / filament-excel

Excel Export for Filament Admin Resources
MIT License
323 stars 68 forks source link

Excel Records - Notification #161

Closed MasterAdmin2 closed 6 months ago

MasterAdmin2 commented 7 months ago

Hello sir i am using laravel with filament's latest version and I installed your module with Composer,

now, I configured it like this on my resource page

ExportAction::make()->exports([
                ExcelExport::make('form')
                    ->except([
                        'created_at',
                        'updated_at',
                        'deleted_at',
                    ])
                    ->fromModel()
                    ->queue()
                    ->withChunkSize(500)
                    ->askForWriterType(),
            ])

now what I want is, to send a notification when the file is ready to download, but it is not saving notifications, as laravel filament provides.

so my question is, is that possible to handle it that way, so that if I come after an hour or day then i can also download the file till I haven't cleared notifications.

adding a snapshot for a better understanding

https://github.com/pxlrbt/filament-excel/assets/28727446/1b2d5967-6ec6-4651-9396-1351020d5a6e

MasterAdmin2 commented 7 months ago

i solved this by adding 2 lines in 2 files, it may help

vendor/pxlrbt/filament-excel/src/Exports/ExcelExport.php inside this file I added

Notification::make()
            ->title(__('filament-excel::notifications.queued.title'))
            ->body(__('filament-excel::notifications.queued.body'))
            ->icon('heroicon-o-arrow-down-tray')
            ->success()
            ->sendToDatabase(auth()->user())
            ->send();`

and inside this file vendor/pxlrbt/filament-excel/src/FilamentExcelServiceProvider.php I added

Notification::make(data_get($export, 'id'))
                ->title(__('filament-excel::notifications.download_ready.title'))
                ->body(__('filament-excel::notifications.download_ready.body'))
                ->success()
                ->icon('heroicon-o-arrow-down-tray')
                ->actions([
                    Action::make('download')
                        ->label(__('filament-excel::notifications.download_ready.download'))
                        ->url($url, shouldOpenInNewTab: true)
                        ->button()
                        ->close(),
                ])
                ->sendToDatabase(auth()->user());

If possible can you implement it in master so that it will be verified by you whenever we run an update update it will be present, and I am pretty sure, everyone will like this.

pxlrbt commented 6 months ago

Closing as duplicate of #108