<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class RemarkResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'commenter' => new UserResource($this->commenter),
            'owner_id' => $this->owner_id,
            'content' => $this->content,
            'created_at' => $this->created_at->format('d-m-Y H:i'),
            'long_ago' => $this->created_at->diffForHumans()
        ];
    }
}
