Answer the question
In order to leave comments, you need to log in
How to make correct json output?
Through foreach, I iterate and insert data into the array:
foreach ($banners as $key => $id) {
$banner = Banner::where('id', $id)->first();
$this->data[$key] = array(
'id' => $banner->id,
'url' => $banner->url,
'name' => $banner->name,
'image' => $banner->image
);
}
Answer the question
In order to leave comments, you need to log in
You are this:
array(
'id' => $banner->id,
'url' => $banner->url,
'name' => $banner->name,
'image' => $banner->image
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question