Skip to content

Commit 95200f4

Browse files
Baspaclaude
andauthored
fix: add defensive check for mail_id in download view (#114)
The $getState() function may return a string instead of a model in some contexts. This fix adds a type check and only renders the download button when a valid attachment object with mail_id is available. Fixes #69 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9fbd691 commit 95200f4

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
@php
2+
$attachment = $getState();
3+
$mailId = is_object($attachment) ? $attachment->mail_id : null;
4+
@endphp
5+
6+
@if($mailId && $attachment)
17
<a type="button"
28
href="{{ route('filament.' . Filament\Facades\Filament::getCurrentPanel()->getId() . '.mails.attachment.download', [
39
'tenant' => Filament\Facades\Filament::getTenant(),
4-
'mail' => $getState()->mail_id,
5-
'attachment' => $getState()->id,
6-
'filename' => $getState()->filename,
10+
'mail' => $mailId,
11+
'attachment' => $attachment->id,
12+
'filename' => $attachment->filename,
713
]) }}"
814
class="rounded-md bg-white px-3.5 py-2.5 text-sm font-semibold cursor-pointer text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50">Download</a>
15+
@endif

0 commit comments

Comments
 (0)