@extends('layouts.sidebar') @section('content')
Unit # | Property Name | JAN | FEB | MAR | APR | MAY | JUN | JUL | AUG | SEPT | OCT | NOV | DEC |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{ $unit->unit_name }} | {{ $unit->property->property_name }} | @foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEPT', 'OCT', 'NOV', 'DEC'] as $month) @php // Convert month name to numeric format $monthNumber = date('n', strtotime($month)); $payment = $unit->leases ->flatMap(function ($lease) use ($monthNumber, $year) { return $lease->payments->filter(function ($payment) use ( $monthNumber, $year, ) { return $payment->payment_date->format('n') == $monthNumber && $payment->payment_date->format('Y') == $year; }); }) ->sum('Amount'); // Show 0 if no payments found $payment = $payment ?: 0; @endphp{{ number_format($payment, 2) }} | @endforeach