Files
mykopkb-be/Modules/Investment/Transformers/UserLimitProfileResource.php
T

32 lines
1.0 KiB
PHP

<?php
namespace Modules\Investment\Transformers;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class UserLimitProfileResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'user_id' => $this->user_id,
'profile_id' => $this->profile_id,
'effective_date' => $this->effective_date?->toDateString(),
'expiry_date' => $this->expiry_date?->toDateString(),
'created_at' => $this->created_at?->toISOString(),
'user' => $this->whenLoaded('user', fn () => [
'id' => $this->user->id,
'name' => $this->user->name,
'email' => $this->user->email,
]),
'profile' => $this->whenLoaded('profile', fn () => [
'id' => $this->profile->id,
'name' => $this->profile->name,
'description' => $this->profile->description,
]),
];
}
}