Skip to content

Commit 6d49b33

Browse files
Develop (#403)
* add filament-excel for s3 * fix notification * wip * export * fix export download
1 parent 5aa4ee4 commit 6d49b33

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

app/Notifications/Admin/ExportExcelNotification.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ public function via(object $notifiable): array
4545
*/
4646
public function toMail(object $notifiable): MailMessage
4747
{
48+
$file = Storage::disk('filament-excel')->exists($this->filename)
49+
? Storage::disk('filament-excel')->get($this->filename)
50+
: null;
51+
4852
return (new MailMessage)
4953
->subject(__('notification.export_finished.title'))
5054
->line(__('notification.export_finished.body', ['filename' => $this->filename]))
51-
->attach(Storage::disk('filament-excel')->path($this->filename));
52-
// ->action(__('notification.export_finished.action'), Storage::disk('filament-excel')->url($this->filename));
55+
->attachData($file, $this->filename)
56+
->action(__('notification.export_finished.action'), $this->generateURL());
5357
}
5458

5559
/**
@@ -73,11 +77,11 @@ public function toDatabase(): array
7377
->seconds(5)
7478
->icon('heroicon-o-inbox-in')
7579
->actions([
76-
// Action::make('export_excel')
77-
// ->label(__('filament-excel::notifications.download_ready.download'))
78-
// ->url($this->generateURL(), shouldOpenInNewTab: true)
79-
// ->button()
80-
// ->close(),
80+
Action::make('export_excel')
81+
->label(__('filament-excel::notifications.download_ready.download'))
82+
->url($this->generateURL(), shouldOpenInNewTab: true)
83+
->button()
84+
->close(),
8185
])
8286
->getDatabaseMessage();
8387
}

app/Providers/AppServiceProvider.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ public function register(): void
2828
config([
2929
'filament.default_filesystem_disk' => config('filesystems.default_public'),
3030
]);
31+
config()
32+
->set('filesystems.disks.filament-excel', [
33+
'driver' => config('filesystems.disks.s3private.driver'),
34+
'key' => config('filesystems.disks.s3private.key'),
35+
'secret' => config('filesystems.disks.s3private.secret'),
36+
'token' => config('filesystems.disks.s3private.token'),
37+
'region' => config('filesystems.disks.s3private.region'),
38+
'bucket' => config('filesystems.disks.s3private.bucket'),
39+
'url' => config('filesystems.disks.s3private.url'),
40+
'endpoint' => config('filesystems.disks.s3private.endpoint'),
41+
'use_path_style_endpoint' => config('filesystems.disks.s3private.use_path_style_endpoint'),
42+
'visibility' => config('filesystems.disks.s3private.visibility'),
43+
'throw' => config('filesystems.disks.s3private.throw'),
44+
'root' => config('filesystems.disks.s3private.root') . 'filament-excel/',
45+
]);
3146
}
3247

3348
/**

routes/web.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,14 @@
8383
Route::post('/{project:slug}/volunteer', 'volunteer')->name('volunteer')->middleware('throttle:register-volunteer');
8484
});
8585

86+
Route::get('filament-excel/{path}', function (string $path) {
87+
if (! Storage::disk('filament-excel')->exists($path)) {
88+
abort(404);
89+
}
90+
91+
return Storage::disk('filament-excel')->download($path);
92+
})
93+
->where('path', '.*')
94+
->name('filament-excel-download');
95+
8696
Route::get('/{page:slug}', PageController::class)->name('page');

0 commit comments

Comments
 (0)