我正在使用运费系统来计算运费。
这就是我目前在刀片中得到的结果:
如你所见,我获得状态id
,然后状态name
。
这是我的功能:
public function index() {
$data = RajaOngkir::Provinsi()->all();
return view('welcome', compact('data'));
}
这是我的刀片代码:
@foreach($data as $sss)
@foreach($sss as $numbers)
{{ $numbers }} <br>
@endforeach
@endforeach
这里是{{$data}}
转储信息:
我想要的是分别获取
id
和name
,以便我可以使用它 在输入中。
答案 0 :(得分:1)
无论如何,foreach将循环并提取相关信息。然后你就可以在刀片中显示它:
@foreach ($data as $info)
ID: {{ $info->province_id }} <br />
Name: {{ $info->province }}
@endforeach
<强>更新强>
从我的重新阅读中你想要它作为一个表格下拉选择,这样你就可以计算运费,因此你只需这样做:
<select name="province" id="">
<option value="">Select</option> -> This will be the default select option
@foreach ($data as $info)
<option value="{{ $info->province_id }}">{{ $info->province }}</option>
@endforeach
</select>