neoban/backend/app/Data/ChatResponseDto.php
kushal-saha 8e2ced8bed Implement new JSON:API Resource for the api responses.
Implement Authentication States, show logout options in auth store and services.
Make DB and controllers to make messages grouped by chats.
Refactor backend code to use DTO.
2026-04-28 12:38:46 +00:00

29 lines
629 B
PHP

<?php
namespace App\Data;
use App\Models\Chat;
use Carbon\CarbonInterface;
final readonly class ChatResponseDto
{
public function __construct(
public string $id,
public CarbonInterface $createdAt,
public CarbonInterface $updatedAt,
public string $userId,
public ?string $title = null,
) {}
public static function fromModel(Chat $chat)
{
return new self(
id: $chat->id,
createdAt: $chat->created_at,
updatedAt: $chat->updated_at,
userId: $chat->user_id,
title: $chat->title ?? null,
);
}
}