client id reports
This commit is contained in:
parent
44cfb2b170
commit
4c29eb106e
@ -23,13 +23,21 @@ private function groupAndSumPaymentsByYear($payments)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reports()
|
public function reports(Request $request)
|
||||||
{
|
{
|
||||||
|
$clientId = $request->get('client_id');
|
||||||
$today = Carbon::today();
|
$today = Carbon::today();
|
||||||
$paymentsInThisYear = Payment::whereBetween(
|
$paymentQuery = Payment::whereBetween(
|
||||||
'created_at',
|
'created_at',
|
||||||
[$today->startOfYear()->toDateTimeString(), $today->endOfYear()->toDateTimeString()]
|
[$today->startOfYear()->toDateTimeString(), $today->endOfYear()->toDateTimeString()]
|
||||||
)->get();
|
);
|
||||||
|
|
||||||
|
if($clientId) {
|
||||||
|
$paymentQuery->whereHas('project', function($query) use ($clientId) {
|
||||||
|
return $query->where('client_id', '=', $clientId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$paymentsInThisYear = $paymentQuery->get();
|
||||||
$thisYearPaymentGroup = $this->groupAndSumPaymentsByYear($paymentsInThisYear);
|
$thisYearPaymentGroup = $this->groupAndSumPaymentsByYear($paymentsInThisYear);
|
||||||
|
|
||||||
$lastYearToday = $today->clone()->modify('-1 year');
|
$lastYearToday = $today->clone()->modify('-1 year');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user