how to display or call value in array in laravel blade view ?
I already have the data that appears in the image below:
I still don't understand how to call the data in the :
<h3>@currency($laporan->Total_Sayur)</h3>
I'm tired of trying it in various ways and it always appears another error message. Please help me
MyController
public function index()
{
$users = User::count();
$kelompok = Kelompok::count();
$anggota = Anggota::count();
$laporan = Anggota::select('kecamatan', Produk::raw('avg(total_sayur) as Total_Sayur, avg(total_buah) as Total_Buah,avg(total_ikan) as Total_Ikan, avg(total_ternak) as Total_Ternak'))
->leftjoin('produk', 'produk.anggota_id', '=', 'anggota.id')
->where('kecamatan', '=', 'Ngajum')
->GroupBy('kecamatan')
->get();
// return $laporan;
return view('Dashboard.index', compact('users', 'kelompok', 'anggota', 'laporan'));
}
View
<div class="row">
<div class="col-lg-3 col-6">
<!-- small box -->
<div class="small-box bg-info">
<div class="inner">
<h3>@currency($laporan->Total_Sayur)</h3>
<p>TOTAl KEMANFAATAN</p>
</div>
<div class="icon">
<i class="ion ion-pricetagg"></i>
</div>
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
</div>
</div>
</div>
Your solution start from here....
<div class="row">
<div class="col-lg-3 col-6">
@foreach($laporan as $item)
<!-- small box -->
<div class="small-box bg-info">
<div class="inner">
<h3>@currency($item->Total_Sayur)</h3>
<p>TOTAl KEMANFAATAN</p>
</div>
<div class="icon">
<i class="ion ion-pricetagg"></i>
</div>
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
</div>
@endforeach
</div>
</div>