diff --git a/config/zeus-bolt.php b/config/zeus-bolt.php index b27c0320..cca2730a 100644 --- a/config/zeus-bolt.php +++ b/config/zeus-bolt.php @@ -53,11 +53,11 @@ 'defaultMailable' => \LaraZeus\Bolt\Mail\FormSubmission::class, - 'uploadDisk' => 'public', + 'uploadDisk' => env('BOLT_FILESYSTEM_DISK', 'public'), - 'uploadDirectory' => 'forms', + 'uploadDirectory' => env('BOLT_FILESYSTEM_DIRECTORY', 'forms'), - 'uploadVisibility' => 'public', + 'uploadVisibility' => env('BOLT_FILESYSTEM_VISIBILITY', 'public'), 'show_presets' => false, diff --git a/resources/views/filament/fields/file-upload.blade.php b/resources/views/filament/fields/file-upload.blade.php index 7f04faee..aabf3ef0 100644 --- a/resources/views/filament/fields/file-upload.blade.php +++ b/resources/views/filament/fields/file-upload.blade.php @@ -6,7 +6,7 @@ target="_blank" size="sm" outlined - href="{{ Storage::disk(config('zeus-bolt.uploadDisk'))->url($file) }}" + href="{{ $getUrl($file) }}" > {{ __('view file') .': '. $loop->iteration }} @@ -15,4 +15,4 @@ @else {{ __('no file uploaded') }} @endif - \ No newline at end of file + diff --git a/src/Fields/Classes/FileUpload.php b/src/Fields/Classes/FileUpload.php index 804b7e39..ec7c2d1e 100644 --- a/src/Fields/Classes/FileUpload.php +++ b/src/Fields/Classes/FileUpload.php @@ -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; @@ -69,10 +70,17 @@ 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')); + + $getUrl = fn($file) => config('zeus-bolt.uploadVisibility') === 'private' + ? $disk->temporaryUrl($file, now()->addDay()) + : $disk->url($file); + return view('zeus::filament.fields.file-upload') ->with('resp', $resp) ->with('responseValue', $responseValue) ->with('field', $field) + ->with('getUrl', $getUrl) ->render(); }