- Removed `SocialMediaService` and migrated core post generation logic to `GeneratePostService`. - Added `GetAllChatMessagesAction` for fetching chat history. - Introduced `MessageDto`, `MessageResource`, and `MessageCollection` for consistent backend API responses. - Updated frontend state and services to support JSON:API-compliant chat messages and history retrieval. - Improved typings and casting for chat message data.
19 lines
446 B
PHP
19 lines
446 B
PHP
<?php
|
|
|
|
namespace App\Actions\Chats;
|
|
|
|
use App\Data\Chats\MessageDto;
|
|
use App\Models\Chat;
|
|
use Illuminate\Pagination\AbstractPaginator;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
class GetAllChatMessagesAction
|
|
{
|
|
public function messages(Chat $chat): AbstractPaginator|LengthAwarePaginator
|
|
{
|
|
$messages = $chat->messages()->oldest()->paginate();
|
|
|
|
return $messages->through(fn ($m) => MessageDto::fromModel($m));
|
|
}
|
|
}
|