these my table database in the model sub_bidang
id id_bidang name
1 1 Backend Developer
2 1 Frontend Developer
3 2 Senior Marketing
i want to display all the name in the array nama sub bidang by field id bidang
$data = Posting::find($id);
foreach ($data->sub_bidang as $value) {
$data = [
'id posting job' => $data->id_posting_job,
'id kategori' => $data->id_kategori,
'nama kategori' => $data->kategori_posting['nama'],
'id bidang' => $data->id_bidang,
'nama bidang' => $data->bidang['nama'],
'nama sub bidang' => [
'bidang' => $value->nama
]
];
return response()->json($data);
}
but doesnt work, just display backend developer in the array nama sub bidang. like this
{
"id posting job": 1,
"id kategori": 1,
"nama kategori": "Part Time",
"id bidang": 1,
"nama bidang": "IT",
"nama sub bidang": {
"bidang": "Backend Developer"
}
}
there should be display backend developer and frontend developer, what the problem ?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lxh1kw
via IFTTT
Aucun commentaire:
Enregistrer un commentaire