<?php

namespace App\Http\Resources\Api\App\Wallet;

use Illuminate\Http\Resources\Json\JsonResource;

class TransactionResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return [
            'id'             => (int) $this->id,
            'title'          => trans('wallet.title.' . $this->type),
            'description'    => trans('wallet.description.' . $this->type, ['amount' => $this->amount]),
            'balance_before' => (float) $this->balance_before,
            'balance_after'  => (float) $this->balance_after,
            'amount'         => (float) $this->amount,
            'type'           => $this->type,
            // 'created_at'     => $this->created_at?->translatedFormat('l j F Y, h:iA')
            'created_at'     => $this->created_at->timestamp
        ];
    }
}
