wyn
wyn
FFilament
Created by wyn on 1/3/2024 in #❓┊help
Preview images from S3
Found the answer, you have to pass the name (with the folder prefix if you have one) to do that you can go to EditResource override mutateFormDataBeforeFill and add the prefix for each file, then it will be generated a s3 temporary link and you ll be able to preview it
3 replies
FFilament
Created by wyn on 1/3/2024 in #❓┊help
Preview images from S3
>schema([ FileUpload::make('media') ->disk('s3') ->imageEditorAspectRatios([ null, '16:9', '4:3', '1:1', ]) ->imageEditor() ->multiple() ->visibility('private') ->maxFiles(5) ]) ->collapsible(),
3 replies
FFilament
Created by Mark Chaney on 12/20/2023 in #❓┊help
SpatieMediaLibraryUpload replace file in collection
and in createProduct which is app/Filament/Resources/Shop/ProductResource/Pages/CreateProduct.php protected function handleRecordCreation(array $data): Model { $productModel = parent::handleRecordCreation($data); if (isset($data['media'])) { $mediaPath = $data['media']; if (is_array($mediaPath)) { foreach ($mediaPath as $path) { $productModel->addMediaFromDisk($path, 's3')->toMediaCollection('products'); } } } return $productModel; } }
8 replies
FFilament
Created by Mark Chaney on 12/20/2023 in #❓┊help
SpatieMediaLibraryUpload replace file in collection
i used Forms\Components\Section::make('Images') ->schema([ FileUpload::make('media') ->preserveFilenames() ->disk('s3') ->imageEditorAspectRatios([ null, '16:9', '4:3', '1:1', ]) ->imageEditor() ->multiple() ->visibility('private') ->maxFiles(5) ]) ->collapsible()
8 replies
FFilament
Created by Mark Chaney on 12/20/2023 in #❓┊help
SpatieMediaLibraryUpload replace file in collection
Maybe you can create a new form which inherits SpatieMediaLibraryFileUpload and override that method
8 replies
FFilament
Created by wyn on 12/24/2023 in #❓┊help
Can't create a custom field
<?php namespace App\Forms\Components; use Filament\Forms\Components\Field; use Illuminate\View\View; class FileUploadColorForm extends Field { public $colors = []; protected string $view = 'forms.components.file-upload-color'; public function getImages() { $images = []; $files = \Storage::disk('livewire-tmp')->files();
foreach ($files as $file) { $images[] = [ 'file' => 'livewire-tmp/' . $file, ];
if (!isset($this->colors['livewire-tmp/' . $file])) { $this->colors['livewire-tmp/' . $file] = 'none'; logger($this->colors); } }
return $images; } public function render(): View { $this->getImages(); return view($this->view, ['colors' => $this->getImages()]); } public function mount() { \Log::info('Component state:', $this->colors); }
}
2 replies