This commit is contained in:
kroutony 2022-07-09 22:29:19 +08:00
parent 78420a72f8
commit 5b9ff7c445
2 changed files with 5 additions and 5 deletions

View File

@ -34,12 +34,12 @@ public function reports(Request $request)
[$today->startOfYear()->toDateTimeString(), $today->endOfYear()->toDateTimeString()] [$today->startOfYear()->toDateTimeString(), $today->endOfYear()->toDateTimeString()]
); );
$client = null; $requestClient = null;
if($clientId) { if($clientId) {
$paymentQuery->whereHas('project', function($query) use ($clientId) { $paymentQuery->whereHas('project', function($query) use ($clientId) {
return $query->where('client_id', '=', $clientId); return $query->where('client_id', '=', $clientId);
}); });
$client = Client::find($clientId); $requestClient = Client::find($clientId);
} }
$paymentsInThisYear = $paymentQuery->get(); $paymentsInThisYear = $paymentQuery->get();
$thisYearPaymentGroup = $this->groupAndSumPaymentsByYear($paymentsInThisYear); $thisYearPaymentGroup = $this->groupAndSumPaymentsByYear($paymentsInThisYear);
@ -63,6 +63,6 @@ public function reports(Request $request)
'sum' => $lastYearPaymentGroup->sum(), 'sum' => $lastYearPaymentGroup->sum(),
], ],
]; ];
return view('reports', ['data' => $data, 'client' => $client, 'clients' => $clients]); return view('reports', ['data' => $data, 'requestClient' => $requestClient, 'clients' => $clients]);
} }
} }

View File

@ -22,8 +22,8 @@
</form> </form>
</div> </div>
@if($client) @if($requestClient)
<div>客戶: {{ $client->name }}</div> <div>客戶: {{ $requestClient->name }}</div>
@endif @endif
今年 ({{ $data['thisYearPaymentGroup']['year'] }}) 總收入 {{ $data['thisYearPaymentGroup']['sum'] }} 今年 ({{ $data['thisYearPaymentGroup']['year'] }}) 總收入 {{ $data['thisYearPaymentGroup']['sum'] }}