<?php

namespace Modules\Internal\Transformers;

use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;

class AuditTrailResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request
     * @return array
     */
    public function toArray($request)
    {
        $audit_trail = [
            'id' => $this->id,
            'old_values' => json_decode($this->old_values),
            'new_values' => json_decode($this->new_values),
            'action' => $this->action,
            'user_id' => $this->user->email,
            'created_at' =>  $this->created_at,
            'updated_at' => $this->updated_at,
        ];

        return $audit_trail;
    }
}
