[WIP] Update Claim Table
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user