Comments (2)
if you wish use eloquent
Chat::where() or scope
https://laravel.com/docs/8.x/eloquent
You can generate queries of your own.
dont forget
https://github.com/musonza/chat#data-transformers
from chat.
You can reuse the getConversationMessages
function from here:
chat/src/Models/Conversation.php
Line 319 in a229349
Like this:
$conversation = Chat::conversations()->getById(request('id'));
$tablePrefix = 'chat_';
$paginationParams = [
'pageName' => 'page',
'page' => request('page') ? request('page') : 1,
'perPage' => 10,
'sorting' => "desc"
];
$message_types = array(); // <- Add message types to this array
$messages = Chat::conversation($conversation)->setParticipant($user)
->conversation
->messages()
->join($tablePrefix.'message_notifications', $tablePrefix.'message_notifications.message_id', '=', $tablePrefix.'messages.id')
->where($tablePrefix.'message_notifications.messageable_type', $user->getMorphClass())
->where($tablePrefix.'message_notifications.messageable_id', $user->getKey())
->when(!empty($message_types), function($query) use ($message_types) {
$query->whereIn('type', $message_types);
})
->orderBy($tablePrefix.'messages.id', $paginationParams['sorting'])
->paginate(
$paginationParams['perPage'],
[
$tablePrefix.'message_notifications.updated_at as read_at',
$tablePrefix.'message_notifications.deleted_at as deleted_at',
$tablePrefix.'message_notifications.messageable_id',
$tablePrefix.'message_notifications.id as notification_id',
$tablePrefix.'message_notifications.is_seen',
$tablePrefix.'message_notifications.is_sender',
$tablePrefix.'messages.*',
],
$paginationParams['pageName'],
$paginationParams['page']
);
from chat.
Related Issues (20)
- Dependency issue in Laravel Framework 5.8.38 HOT 2
- Conversation with hundreds of participants cause error on mass insert: Prepared statement contains too many placeholders HOT 11
- Additional field in chat_message model HOT 5
- Get all messages for a user
- Call to a member function only() on null error HOT 1
- Error Call to undefined method Musonza\Chat\Services\MessageService::data() HOT 1
- Customize broadcast queue and connection in config
- A way of including all participation message_notifications
- Laravel 9 Support HOT 9
- Get all participant Models that a Model ever had a conversation with
- Method ConversationService::common() does not exist HOT 1
- $conversation = Chat::conversations()->between($participantModel1, $participantModel2); is not work HOT 2
- how to get conversations with unreadCount HOT 1
- make sure you get conversations that are direct, and make sure direct_message column is 1.
- Attempted to lazy load [participation] on model [Musonza\Chat\Models\Message] but lazy loading is disabled.
- The conversation's method 'between' is not giving the correct count
- Chat/messaging
- how to specify columns in chat participants HOT 1
- Participation always returns the first one regardless of the assigned conversation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chat.