Skip to content

Commit

Permalink
Improved link to files in Datasheet
Browse files Browse the repository at this point in the history
  • Loading branch information
MGeurts committed Dec 18, 2024
1 parent 61591b3 commit 9c8b9a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions app/Livewire/People/Datasheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
use Illuminate\Support\Facades\File;
use Illuminate\View\View;
use Livewire\Component;
use Illuminate\Support\Collection;

class Datasheet extends Component
{
public $person;

public array $images = [];

public array $files = [];
public Collection $files;

/**
* Mount the component and load relevant data.
Expand All @@ -26,10 +27,8 @@ public function mount(): void
->map(fn ($path) => basename($path)) // Extract filename with extension
->toArray();

// Load the media files associated with the person and extract only filenames (including extensions)
$this->files = $this->person->getMedia('files')
->map(fn ($media) => basename($media->getPath())) // Extract filename with extension from media path
->toArray();
// Load the media files associated with the person
$this->files = $this->person->getMedia('files');
}

/**
Expand Down
4 changes: 3 additions & 1 deletion resources/views/livewire/people/datasheet.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@
<tr>
<td colspan="3">&nbsp;</td>
<td>
{{ $file }}
<x-link href="{{ $file->getUrl() }}" target="_blank" title="{{ __('app.download') }}">
{{ $file->file_name }}
</x-link>
</td>
</tr>
@endforeach
Expand Down

0 comments on commit 9c8b9a1

Please sign in to comment.