-
Anonymous
Вставить URL-адрес пути в массив значений
Сообщение
Anonymous »
Я хочу добавить изображение URL в массив
Код: Выделить всё
public function show(){
$halls = DB::table('halls')
->join('imagas','halls.id','=','imagas.id_Halls')
->select('halls.id','halls.hall_name','halls.hall_adress','halls.hall_details','price_hours','price_int','halls.hall_name','imagas.image_path')->where('halls.id',157)
->get();
$results=[];
foreach ($halls as $hall) {
$array=json_decode($hall->image_path,true);
if (is_array($array))
{
$hall->image_path = $array;
}
array_push($results, $hall);
}
return response()->json($results);
}
вывести вот так
{
"id": 157,
"hall_name": "ali",
"hall_adress": "st-50",
"hall_details": null,
"price_hours ": "3000",
"price_int": "500",
"image_path": [
"1579635535.jpg",
"1579635536.jpg",
" 1579635537.png",
"1579635538.png"
]
но мне нужно передать URL-адрес строкового пути в массив и отобразить вывод следующим образом
{
"id": 157,
"имя_зала": "ali",
"адрес_зала": "st -50",
"hall_details": null,
"price_hours": "3000",
"price_int": "500",
"image_path": [
"
http://127.0. 0.1:8000/images_ravs/1579635535.jpg",
"
http://127.0.0.1:8000/images_ravs/1579635536.jpg",
"
http://127.0.0.1:8000/images_ravs/1579635537.png",
"
http://127.0.0.1:8000/images_ravs/1579635538.png"
]
Подробнее здесь:
https://stackoverflow.com/questions/601 ... s-an-array
1733102341
Anonymous
[b]Я хочу добавить изображение URL в массив[/b]
[code]public function show(){
$halls = DB::table('halls')
->join('imagas','halls.id','=','imagas.id_Halls')
->select('halls.id','halls.hall_name','halls.hall_adress','halls.hall_details','price_hours','price_int','halls.hall_name','imagas.image_path')->where('halls.id',157)
->get();
$results=[];
foreach ($halls as $hall) {
$array=json_decode($hall->image_path,true);
if (is_array($array))
{
$hall->image_path = $array;
}
array_push($results, $hall);
}
return response()->json($results);
}
[/code]
[b]вывести вот так[/b]
{
"id": 157,
"hall_name": "ali",
"hall_adress": "st-50",
"hall_details": null,
"price_hours ": "3000",
"price_int": "500",
"image_path": [
"1579635535.jpg",
"1579635536.jpg",
" 1579635537.png",
"1579635538.png"
]
[b]но мне нужно передать URL-адрес строкового пути в массив и отобразить вывод следующим образом[/b]
{
"id": 157,
"имя_зала": "ali",
"адрес_зала": "st -50",
"hall_details": null,
"price_hours": "3000",
"price_int": "500",
"image_path": [
"http://127.0. 0.1:8000/images_ravs/1579635535.jpg",
"http://127.0.0.1:8000/images_ravs/1579635536.jpg",
"http://127.0.0.1:8000/images_ravs/1579635537.png",
"http://127.0.0.1:8000/images_ravs/1579635538.png"
]
Подробнее здесь: [url]https://stackoverflow.com/questions/60130886/insert-path-url-into-values-an-array[/url]