New-Thanasoft/thanasoft-back/app/Http/Resources/Webmail/WebmailMessageResource.php
2026-05-04 16:46:14 +03:00

44 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources\Webmail;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class WebmailMessageResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'user_id' => $this->user_id,
'message_uid' => $this->message_uid,
'direction' => $this->direction,
'folder' => $this->folder,
'status' => $this->status,
'from_email' => $this->from_email,
'from_name' => $this->from_name,
'to' => $this->to_recipients ?? [],
'cc' => $this->cc_recipients ?? [],
'bcc' => $this->bcc_recipients ?? [],
'subject' => $this->subject,
'body' => $this->body,
'snippet' => $this->snippet,
'attachments' => $this->attachments ?? [],
'metadata' => $this->metadata ?? [],
'is_read' => $this->read_at !== null,
'is_starred' => $this->starred_at !== null,
'read_at' => $this->read_at,
'starred_at' => $this->starred_at,
'sent_at' => $this->sent_at,
'received_at' => $this->received_at,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}