<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class MessageResource extends JsonResource
{
	/**
	 * Transform the resource into an array.
	 *
	 * @param \Illuminate\Http\Request $request
	 * @return array
	 */
	public function toArray($request)
	{
		//return parent::toArray($request);
		return [
			'id'                   => $this->id,
			'conversation_id'      => $this->conversation_id,
			'sender_id'            => $this->sender_id,
			'sender_name'          => $this->sender ? $this->sender->name : 'Worker',
			'sender_furigana_name' => $this->sender ? $this->sender->furigana_name : null,
			'sender_avatar'        => $this->sender ? $this->sender->avatar : 'avatar.png',
			'content'              => $this->content,
			'content_type'         => $this->content_type,
			'type'                 => $this->type,
			'file_path'            => $this->file_path,
			'is_read'              => $this->is_read,
			'read_at'              => $this->read_at,
			'created_at'           => $this->created_at,
		];
	}
}