Skip to content

Commit 02f1088

Browse files
fix export download
1 parent 378c71d commit 02f1088

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

app/Notifications/Admin/ExportExcelNotification.php

Lines changed: 6 additions & 2 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
/**

routes/web.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@
8484
});
8585

8686
Route::get('filament-excel/{path}', function (string $path) {
87-
return
88-
response()
89-
->download(Storage::disk('filament-excel')->path($path), substr($path, 37))
90-
->deleteFileAfterSend();
87+
if (! Storage::disk('filament-excel')->exists($path)) {
88+
abort(404);
89+
}
90+
91+
return Storage::disk('filament-excel')->download($path);
9192
})
9293
->where('path', '.*')
9394
->name('filament-excel-download');

0 commit comments

Comments
 (0)