In this video we are going to learn about Edit Product Gallery.
So let see how can we Edit the Product Gallery.
For that lets open the AdminEditProdcutComponent Class file
And here create two new property first

public $images;
public $newimages;

Now inside the mount method just write here

$this->images = explode(\",\",$product->images);

Now go to the AdminEditProductComponent view file add the following code.

<div class=\"form-group\">
<label class=\"col-md-4 control-label\">Product Gallery</label>
<div class=\"col-md-4\">
<input type=\"file\" class=\"input-file\" wire:model=\"newimages\" multiple />
@if($newimages)
@foreach($newimages as $newimage)
@if($newimage)
<img src=\"{{$newimage->temporaryUrl()}}\" width=\"120\" />
@endif
@endforeach
@else
@foreach($images as $image)
@if($image)
<img src=\"{{asset('assets/images/products')}}/{{$image}}\" width=\"120\" />
@endif
@endforeach
@endif
</div>
</div>


Now go the class file and here inside the updageProduct method and add the following code.

if($this->newimages)
{
if($product->images)
{
$images = explode(\",\",$product->images);
foreach($images as $image)
{
if($image)
{
unlink('assets/images/products'.'/'.$image);
}
}
}

$imagesname ='';
foreach($this->newimages as $key=>$image)
{
$imgName = Carbon::now()->timestamp . $key . '.' . $image->extension();
$image->storeAs('products',$imgName);
$imagesname = $imagesname . ',' . $imgName;
}
$product->images = $imagesname;
}

Now its done so lets check it so switch to browser and refresh the page
And now edit any product and here add the image gallery
Now you can see the image gallery added
Lets check it so go to the shop page
And find this product and here you can see the image gallery
Now lets change this image gallery
So go to the product page and edit this product
Now change the image
And click on update
Now its updated now go the product details page here you cans see the updated product gallery images
So in this way you can edit the product gallery. so that's all about edit product gallery