fix division when member import
This commit is contained in:
37
Modules/Client/Transformers/DashboardResources.php
Normal file
37
Modules/Client/Transformers/DashboardResources.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DashboardResources extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$myLimitBalance = (int)$this->currentPolicy->limit_balance;
|
||||
$myLimitTotal = (int)$this->currentPolicy->total_premi;
|
||||
|
||||
$lockBalance = (int)$this->currentPolicy->minimal_stop_service_net;
|
||||
$lockPercentage = (int)$this->currentPolicy->minimal_stop_service_percentage;
|
||||
|
||||
return [
|
||||
'policy' => [
|
||||
'myLimit' => [
|
||||
'balance' => $myLimitBalance,
|
||||
'total' => $myLimitTotal,
|
||||
'percentage' => ($myLimitBalance / $myLimitTotal) * 100,
|
||||
],
|
||||
'lockLimit' => [
|
||||
'balance' => $lockBalance,
|
||||
'percentage' => $lockPercentage
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user