39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Client\Transformers;
|
|
|
|
use App\Helpers\Helper;
|
|
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
|
|
]
|
|
],
|
|
];
|
|
}
|
|
}
|