[WIP] Update Claim Table

This commit is contained in:
R
2022-12-05 16:20:09 +07:00
parent 3bc8877740
commit 885edec290
6 changed files with 69 additions and 17 deletions

View File

@@ -4,6 +4,8 @@ namespace App\Services;
use App\Models\Claim;
use App\Models\Icd;
use App\Models\Member;
use Carbon\Carbon;
use Str;
class ClaimService{
@@ -24,4 +26,19 @@ class ClaimService{
return $claim;
}
public static function getMemberTotalUsage(Member $member, $startDate = null, $endDate = null)
{
$startDate = empty($startDate) ? Carbon::now()->startOfMonth() : $startDate;
$endDate = empty($endDate) ? Carbon::now()->startOfMonth() : $endDate;
$claims = $member->claims()
->used($startDate, $endDate)
->get();
$total = $claims->sum(function($claim){
return $claim->total_claim;
});
return $total;
}
}