Editing multiple images

Hello, in my admin Panel I have model PointOfSale with the related CreatePointOfSalePage. Also, i have another model called PosImage . Between the pointOfSale model and the PosImage there's an hasMany relation called pictures(). In the create page I have adde a file upload field that correctly uploads each picture to digital ocean spaces.
2 Replies
Gianmarco Varrone
This is the file upload I'm using in the form: Section::make('Fotografie') ->description("Carica almeno 10 fotografie") ->schema([ Forms\Components\FileUpload::make('photos') ->multiple() ->enableDownload() ->enableOpen() ->enableReordering() ->disk('do_spaces') ->directory("photos/". Carbon::now()->format('Y'). "/".Carbon::now()->format('m'). "/".Carbon::now()->format('d'). "/") ->visibility('public') ->image() ->imageResizeMode('cover') ->imageCropAspectRatio('16:9') ->imageResizeTargetWidth('1920') ->imageResizeTargetHeight('1080'), ])->columns(1) And in the after create I'm doing : protected function afterCreate(): void { foreach($this->data['photos'] as $key=>$value){ $data = [ 'point_of_sale_id'=>$this->record->id, 'do_cdn_url' => 'https://closbox.ams3.cdn.digitaloceanspaces.com/' . $value, ]; PosImage::create($data); } } Now, I would like to allow the user, from the EditPage to be able to adit the previously uploaded images. The issue is that I don't know how i can show all the uploaded images to the user Is there anybody that can help with this matter? Thank you
Dan Harrin
Dan Harrin2y ago
you should probably use the mutate() functions on fill and save to do this then you can handle both case check the docs BUT i would reccomend spatie media library instead, i dont see the point of reinventing this image model

Did you find this page helpful?