laravel-starter/app/Http/Resources/Messaging/MessageResource.php

28 lines
678 B
PHP

<?php
namespace App\Http\Resources\Messaging;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\UserResource;
class MessageResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'senderId' => $this->user_id,
'senderName' => $this->sender_name,
'senderAvatarUrl' => $this->sender_avatar_url,
'body' => $this->body,
'readAt' => $this->read_at,
'createdAt' => $this->created_at,
];
}
}