create table component & connect api for dashboard

This commit is contained in:
Fajar
2023-03-24 09:14:49 +07:00
parent d5dfc7d36c
commit 3c5f06ef26
17 changed files with 745 additions and 681 deletions

View File

@@ -1,11 +1,10 @@
<?php
namespace Modules\Client\Transformers;
namespace Modules\Client\Transformers\Dashboard;
use App\Helpers\Helper;
use Illuminate\Http\Resources\Json\JsonResource;
class DashboardResources extends JsonResource
class LimitResources extends JsonResource
{
/**
* Transform the resource into an array.
@@ -22,17 +21,15 @@ class DashboardResources extends JsonResource
$lockPercentage = (int)$this->currentPolicy->minimal_stop_service_percentage;
return [
'policy' => [
'myLimit' => [
'balance' => $myLimitBalance,
'total' => $myLimitTotal,
'percentage' => $myLimitTotal ? (($myLimitBalance / $myLimitTotal) * 100) : 0,
],
'lockLimit' => [
'balance' => $lockBalance,
'percentage' => $lockPercentage
]
'myLimit' => [
'balance' => $myLimitBalance,
'total' => $myLimitTotal,
'percentage' => $myLimitTotal ? round(($myLimitBalance / $myLimitTotal) * 100, 2) : 0,
],
'lockLimit' => [
'balance' => $lockBalance,
'percentage' => $lockPercentage
]
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace Modules\Client\Transformers;
namespace Modules\Client\Transformers\Dashboard;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -18,15 +18,13 @@ class MemberResources extends JsonResource
'id' => $this->id,
'memberId' => $this->member_id,
'fullName' => $this->full_name,
$this->mergeWhen($request->input('claimMember') === 'false', [
'division' => $this->division->name ?? '',
'status' => $this->active
]),
'division' => $this->division_name ?? '',
'limit' => [
'current' => $this->claims_sum_total_claim,
'total' => $this->currentPlan->limit_rules ?? 0,
'percentage' => (!empty($this->currentPlan->limit_rules ?? 0)) ? (($this->claims_sum_total_claim / $this->currentPlan->limit_rules) * 100) : 0
],
'status' => $this->active,
];
}
}