There is a Posts table that has a column named images. in images I store data as JSON array as:
["p1.jpg", "p2.jpg","p4.jpg","p9.jpg","p11.jpg", "p12.jpg","p13.jpg", "p14.jpg"];
I want to delete one of these images by ajax. I send the id and image by ajax and get that id and image in the controller correctly:
public function remove() {
$imgs = Image::where('id', request()->id)->pluck('images');
return $imgs;
}
reults in console:
[Array(8)]
0: (8) ["p1.jpg", "p2.jpg", "p4.jpg", "p9.jpg", "p11.jpg", "p12.jpg", "p13.jpg", "p14.jpg"]
length: 1
__proto__: Array(0)
also, I get the image name by request()->img from ajax.
$image = request()->img; => p12.jpg
How I can delete the $image from $images array?