neoban/backend/app/Actions/Chats/GetAllChatMessagesAction.php
kushal-saha 20a56d4adc refactor(core): replace SocialMediaService with GeneratePostService, add message fetching and JSON:API resources
- 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.
2026-04-30 09:00:14 +00:00

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));
}
}