@extends('template.app') @section('content')

{{ $title }}

{{--
Free Bootstrap 4 Admin Dashboard
--}}
@if (session('status')) @endif @if (session('error')) @endif

{{ $title }}


@if (Request::get('student')) @endif {{-- --}} @php $no = 1; $balanceInAdvanced = 0; $associativeArray = []; $groupedItems = []; // $mergedItems = []; $associativeArray = collect($data) ->map(function ($data) { return $data->toArray(); }) ->toArray(); $groupedItems = collect($associativeArray)->groupBy('date')->toArray(); @endphp @php if (Request::get('student')) { // Inisialisasi nilai balance_in_advanced dari entry pertama $balanceInAdvanced = $associativeArray[0]['balance_in_advanced']; } @endphp @foreach ($associativeArray as $key => $item) @php if ($key > 0) { if ($item['type'] == 'in') { $balanceInAdvanced += $item['total_point']; } else { $balanceInAdvanced -= $item['total_point']; } } if (Request::get('student') != null) { $openingBalance = DB::table('point_histories') ->where('student_id', $item['student']['id']) ->where('keterangan', 'Opening Balance') ->first(); } @endphp @if (Request::get('student')) @endif @php // Set balance_in_advanced untuk iterasi berikutnya $balanceInAdvanced = $balanceInAdvanced; @endphp @endforeach
# NameOpening BalanceDateDate TimePoint History Detail Type Last Balance
{{ $no++ }} {{ $item['student'] ? ucwords($item['student']['name']) : '-' }}{{ $openingBalance != null ? $openingBalance->total_point : 0 }} {{ $item['date'] ? \Carbon\Carbon::parse($item['date'])->format('d M Y') : '-' }} {{ $item['total_point'] }} {{ $item['keterangan'] }} {{ $item['type'] == 'in' ? 'In' : 'Out' }} {{ $balanceInAdvanced }}
@endsection