Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
Cara mengatasi Undefined offset: 5 di Laravel
error.png
jadi yang buat saya bingung di localhost saya jalankan bisa, tapi pas saya update di server muncul error Undefined offset: 5
KualitasController.php
class KualitasController extends Controller
{
public function kualitas()
{
$result = DB::table('kualitas')
->select('kriteria_id', 'cabangnama_cab', DB::raw('SUM(total_pokok) as total_pokok'),
DB::raw('SUM(total_bruto) as total_bruto'))
->groupBy('kriteria_id')
->get();
$status = DB::table('kriterias')
->select('id', 'keterangan')
->whereIn('id', $result->pluck('kriteria_id'))
->get();
$bruto = array_sum($result->pluck('total_bruto')->toArray());
$pokok = array_sum($result->pluck('total_pokok')->toArray());
return view('kualitas.kualitas',compact('result', 'status' , 'bruto', 'pokok'));
}
kualitas.blade.php
@php
$no = 1;
@endphp
@foreach ($result as $key => $g)
<div class="tbl-content">
<tbody>
<tr>
<td>{{$no++}}</td>
<td align=center><b>{{$status[$key]->keterangan}}</b></td>
<td>{{rupiah($g->total_bruto)}}</td>
<td>{{rupiah($g->total_pokok)}}</td>
<td>{{rupiah($bruto)}}</td>
<td>{{rupiah($pokok)}}</td>
<td>{{number_format((float) (($g->total_bruto+$g->total_pokok)/($bruto+$pokok)*100),2)}} %</td>
</tr>
0
1 Jawaban:
<div>Coba ini<br><br></div><pre>return view('kualitas.kualitas', compact('result'=>$result, 'status'=>$status, 'bruto'=>$bruto, 'pokok'=>$pokok));</pre>
0