@php $i=0;@endphp @foreach ($Students as $Student) @if ($Student->VehicleFee->Route ?? '') @php $SetFeeAmounts = App\Models\StudentVehicleSetFee::where('student_vehicle_route_id', $Student->VehicleFee->id) ->where('batch_year',$Student->batch_year) ->where(function($query) { $query->where('isCancelled',0) ->orWhere('isCancelled',NULL); })->sum('total_amount'); $PayedAmounts = App\Models\StudentVehiclePayFee::where('student_id', $Student->id) ->where('batch_year',$Student->batch_year) ->where(function($query) { $query->where('isCancelled',0) ->orWhere('isCancelled',NULL); })->sum('amount'); $Balance = $SetFeeAmounts - $PayedAmounts; @endphp @if ($Balance > 0)