I have a JSON field in my MySQL table column which has an JSON array with part of images URLs.
"images": [
{
"images": {
"original": "/storage/uploads/1.png",
"300": "/storage/uploads/300.1.png",
"600": "/storage/uploads/600.1.png",
"900": "/storage/uploads/900.1.png"
},
"thumb": "/storage/uploads/300.1.png"
},
{
"images": {
"original": "/storage/uploads/2.png",
"300": "/storage/uploads/300.2.png",
"600": "/storage/uploads/600.2.png",
"900": "/storage/uploads/900.2.png"
},
"thumb": "/storage/uploads/300.2.png"
},
{},
]
I want to get the array with appending a Base URL for each of the values of the array.
"images": [
{
"images": {
"original": "http://localhost:8000/storage/uploads/1.png",
"300": "http://localhost:8000/storage/uploads/300.1.png",
"600": "http://localhost:8000/storage/uploads/600.1.png",
"900": "http://localhost:8000/storage/uploads/900.1.png"
},
"thumb": "http://localhost:8000/storage/uploads/300.1.png"
},
{
"images": {
"original": "http://localhost:8000/storage/uploads/2.png",
"300": "http://localhost:8000/storage/uploads/300.2.png",
"600": "http://localhost:8000/storage/uploads/600.2.png",
"900": "http://localhost:8000/storage/uploads/900.2.png"
},
"thumb": "http://localhost:8000/storage/uploads/300.2.png"
},
{},
]
I have tried with Collections function like below code. But was not succeeded.
'images' => collect($item->images)->map(function ($image) {
return url($image);
})->all(),