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.
29 lines
629 B
PHP
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,
|
|
);
|
|
}
|
|
}
|