You can use DomDocument to handle the added images.
Here is an example, but I could not test it myself.
$dom = new \DomDocument();
$dom->loadHtml($request->body, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$images = $dom->getElementsByTagName('img');
foreach ($images as $key => $img) {
$data = $img->getAttribute('src');
if (preg_match('/data:image\/(png|jpg|jpeg);base64/', $data)) {
preg_match('/data:image\/(png|jpg|jpeg);base64,(.*)/', $data, $matches);
$imageData = base64_decode($matches[2]);
$imageName = 'image_' . time() . '_' . $key . '.png';
file_put_contents(public_path('/uploads/post/') . $imageName, $imageData);
$img->removeAttribute('src');
$img->setAttribute('src', '/uploads/post/' . $imageName);
}
}
$int['body'] = $dom->saveHTML();
You can also use the summernote callbacks for this but then you'll have to handle the upload via API call and add that to your request: https://summernote.org/deep-dive/#onimageupload
But by using this you will need a different approach in your store method to check if the uploaded image is still present in the body before storing the post.