Skip to content

Commit

Permalink
add theFile function
Browse files Browse the repository at this point in the history
check if the file is uploaded or from a URL
  • Loading branch information
atmonshi committed May 20, 2023
1 parent a46fadb commit 45e3e51
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 45e3e51

Please sign in to comment.