36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Investment\Transformers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class UserInvestmentLimitResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'user_id' => $this->user_id,
|
|
'investment_type_id' => $this->investment_type_id,
|
|
'max_investment_amount' => $this->max_investment_amount,
|
|
'max_transaction_amount' => $this->max_transaction_amount,
|
|
'effective_date' => $this->effective_date?->toDateString(),
|
|
'expiry_date' => $this->expiry_date?->toDateString(),
|
|
'created_by' => $this->created_by,
|
|
'created_at' => $this->created_at?->toISOString(),
|
|
'updated_at' => $this->updated_at?->toISOString(),
|
|
'user' => $this->whenLoaded('user', fn () => [
|
|
'id' => $this->user->id,
|
|
'name' => $this->user->name,
|
|
'email' => $this->user->email,
|
|
]),
|
|
'investment_type' => $this->whenLoaded('investmentType', fn () => [
|
|
'id' => $this->investmentType->id,
|
|
'code' => $this->investmentType->code,
|
|
'name' => $this->investmentType->name,
|
|
]),
|
|
];
|
|
}
|
|
}
|