Skip to content

Commit

Permalink
check for upload visibility when generating file urls
Browse files Browse the repository at this point in the history
  • Loading branch information
aSeriousDeveloper committed Dec 12, 2024
1 parent 7767bb2 commit 6af58e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions resources/views/filament/fields/file-upload.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
target="_blank"
size="sm"
outlined
href="{{ Storage::disk(config('zeus-bolt.uploadDisk'))->url($file) }}"
@if(config('zeus-bolt.uploadVisibility') === 'private')
href="{{ $disk->temporaryUrl($file, now()->addMinute()) }}"
@else
href="{{ $disk->url($file) }}"
@endif
>
{{ __('view file') .': '. $loop->iteration }}
</x-filament::link>
Expand All @@ -15,4 +19,4 @@
@else
<span class="text-gray-500">{{ __('no file uploaded') }}</span>
@endif
</div>
</div>
3 changes: 3 additions & 0 deletions src/Fields/Classes/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace LaraZeus\Bolt\Fields\Classes;

use Filament\Forms\Components\Hidden;
use Illuminate\Support\Facades\Storage;
use LaraZeus\Accordion\Forms\Accordion;
use LaraZeus\Accordion\Forms\Accordions;
use LaraZeus\Bolt\Facades\Bolt;
Expand Down Expand Up @@ -68,11 +69,13 @@ public static function getOptionsHidden(): array
public function getResponse(Field $field, FieldResponse $resp): string
{
$responseValue = filled($resp->response) ? Bolt::isJson($resp->response) ? json_decode($resp->response) : [$resp->response] : [];
$disk = Storage::disk(config('zeus-bolt.uploadDisk'));

return view('zeus::filament.fields.file-upload')
->with('resp', $resp)
->with('responseValue', $responseValue)
->with('field', $field)
->with('disk', $disk)
->render();
}

Expand Down

0 comments on commit 6af58e9

Please sign in to comment.