pxlrbt / filament-excel

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

[Feature] Configuration file needed + possibility to set filesystem (S3) disk from config #152

Open ValtersBergs opened 7 months ago

ValtersBergs commented 7 months ago

Hello! For now, the plugin has a disk that is hard-coded locally (filesystems.disks.filament-excel). It would be great if the plugin had a configuration file where you can specify which predefined in filesystems file system to work with. For example - S3.

Currently, the plugin does not work if the laravel site runs on multiple servers, or if another queue server is already in use.

pxlrbt commented 7 months ago

Can't you just override the defined disk to make it work?

ValtersBergs commented 7 months ago

To make override, i need to extend FilamentExcelServiceProvider and override register method (to rewite config), then disable discovery (dont-discover) of pxlrbt/filament-excel in composer json. Than i need to rewrite routes for s3. Yes, i can do this, but then i am stuck with specific plugin version, because i rewrote part of functionality.

routes changes: `Route::get('filament-excel/{path}', function (string $path) { app()->terminating(function () use ($path) { Storage::disk('filament-excel')->delete($path); });

return Storage::disk('filament-excel')->response($path, substr($path, 37));

}) ->where('path', '.*') ->name('filament-excel-download');`

Config with disk setting would be great with manual how to set it, i guess.

ValtersBergs commented 7 months ago

For other users: for dedicated queues you need to publish Maatwebsite excel config and in generated file excel.php set 'remote_disk' => 's3',

  1. php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config
  2. excel.php 'remote_disk' => 's3',
pxlrbt commented 7 months ago

I assume you can just override the configuration in your AppServiceProviders boot() method:

config()->set('filesystems.disks.filament-excel', [
    'driver' => 'your_driver',
    // other configuration option
]);
lloricode commented 7 months ago

I assume you can just override the configuration in your AppServiceProviders boot() method:

config()->set('filesystems.disks.filament-excel', [
    'driver' => 'your_driver',
    // other configuration option
]);

much better setup this via config, then can be visible to the filesystems configuration,