- Added `Sidebar` component with responsive layout for chat navigation. - Implemented `ChatStore` for managing chat data and fetching user chats. - Integrated JSON:API `ChatCollection` for consistent backend responses. - Added `GetUserChatsAction` to retrieve paginated user chats. - Refactored frontend to separate `ChatStore` and `MessageStore` for improved state management. - Updated styles, components, and tests for seamless chat interactions.
19 lines
459 B
PHP
19 lines
459 B
PHP
<?php
|
|
|
|
namespace App\Actions\Chats;
|
|
|
|
use App\Data\Chats\ChatResponseDto;
|
|
use App\Models\User;
|
|
use Illuminate\Pagination\AbstractPaginator;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
final readonly class GetUserChatsAction
|
|
{
|
|
public function chats(User $user): LengthAwarePaginator|AbstractPaginator
|
|
{
|
|
$chats = $user->chats()->latest()->paginate();
|
|
|
|
return $chats->through(fn ($chat) => ChatResponseDto::fromModel($chat));
|
|
}
|
|
}
|