Skip to content

Commit

Permalink
Merge pull request #90 from lara-zeus/the-file
Browse files Browse the repository at this point in the history
add theFile function
  • Loading branch information
atmonshi authored May 20, 2023
2 parents a46fadb + da67087 commit 52ce975
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 3 additions & 4 deletions resources/views/themes/zeus/addons/library-item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,22 @@
</p>

@if($item->type === 'IMAGE')
<img class="mx-auto" src="{{ $item->file_path }}">
<img class="mx-auto" src="{{ $item->theFile() }}">
@endif

@if($item->type === 'FILE')
<div class="text-center">
<x-filament::button tag="a" target="_blank" href="{{ $item->file_path }}" class="mx-auto">
<x-filament::button tag="a" target="_blank" href="{{ $item->theFile() }}" class="mx-auto">
{{ __('Show File') }}
</x-filament::button>
</div>
@endif

@if($item->type === 'VIDEO')
<video width="100%" class="w-full" controls>
<source src="{{ $item->file_path }}">
<source src="{{ $item->theFile() }}">
Your browser does not support HTML video.
</video>
@endif

</x-filament::card>
</div>
9 changes: 9 additions & 0 deletions src/Models/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,13 @@ public function getRouteKeyName()
{
return 'slug';
}

public function theFile()
{
if (! $this->getMedia('library')->isEmpty()) {
return $this->getFirstMediaUrl('library');
}

return $this->file_path;
}
}

0 comments on commit 52ce975

Please sign in to comment.