I got, trouble in my project.. i don't know what should I be like! I hope other seniors and friends can help me with this problem.
This is my controller
public function orderPacket($id){
$data_paket = DB::table('list_packet')->where('list_packet.id', $id)->join('d_list_packet', 'list_packet.id', '=', 'daftar_paket_detail.idPacket')->select('daftar_paket_detail.kode_packet as kode_packet')->get();
foreach ($data_packet as $packet) {
$kode_packet = $paket->kode_packet;
$data_kate = FD::where('kode_packet', $kode_packet)->value('nama_packet');
$packet= DFD::where([
['kode_packet', $kode_menu],
['status', '1'],
])->get();
$data[] = [
'name_category' => $data_kate,
'data_packet' => $packet
];
}
return View('user.order-packet',[
'data' => $data
]);
}
Model data,
name_category = "Packet A",
data_packet = {
[id = 121,
kode_packet = PK-204,
name_packet = Economical 1,
price = 10.00
],
[id = 111,
kode_packet = PK-207,
name_packet = Economical 2,
price = 12.00
],
[id = 145,
kode_packet = PK-214,
name_packet = Economical 3,
price = 15.00
],
}
name_category = "Packet A",
data_packet = {
[id = 132,
kode_packet = PK-204,
name_packet = Economical 1,
price = 10.00
]
}
approxiately like this
And This is my blade
@foreach($data as $category)
<div class="col-12 mb-3">
<label for=""></label>
<select class="form-control nasi mb-1" name="nasi" >
<option value="">Pilih Nasi</option>
@foreach($category->data_packet as $datas)
<option value=""> - </option>
@endforeach
</select>
</div>
@endforeach
click for view controller screeenshot click for view controller screeenshot
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Ue9EC8
via IFTTT
Aucun commentaire:
Enregistrer un commentaire