Check out Firebase, they have a PHP package. Real-time communication is what you need.
Using messaging system
I'm using this package - https://github.com/cmgmyr/laravel-messenger But how can I use something to refresh after every minute or so so that messages get displayed.
Ideally need a package not external or use something else
@lstables look at pusher.com, while it isn't a package, you could build the messaging part yourself and use pusher to get real time updates. Jeffrey has done a couple of lessons on it too.
@mstnorris hey yes forgot about that, cheers.
@lstables thanks for using my messenger package! I played around with pusher and made a little demo here - https://github.com/cmgmyr/laravel-messenger-pusher-demo it's not 100% complete, but you can use it as a base to get started. If you have any questions, feel free to enter an issue in GitHub
Hi @cmgmyr great package by the way I didn't see the Laravel 5/pusher version til after I had watched the laracasts on pusher and just implemented how @JeffreyWay shows us and I've got it to work in a way just need a little tweaking now but all good thanks for providing the package.
Hi @cmgmyr ! I'm using your package in my project and I have a problem with searching.
I need to search threads by participant firstName, lastName and email.
I'm trying to implement it in this way:
$threads = Thread::latest('updated_at')
->whereHas('participants', function($query) use($q) {
$query->whereHas('user', function($query) use($q) {
$query->where('lastName', 'LIKE', '%'.$q.'%');
})
->orWhereHas('user', function($query) use($q) {
$query->where('firstName', 'LIKE', '%'.$q.'%');
})
;
})
->with(['participants' => function($query) {
$query->with('user');
}])
->forUser($userId)
->paginate($limit)
;
It works fine if you search by lastName.But if you type firstName it will return the whole rows. To avoid this I've tried to comment :
->orWhereHas('user', function($query) use($q) {
$query->where('firstName', 'LIKE', '%'.$q.'%');
})
And it works fine, but it is necessary no search by firstName or lastName or email.
Have you got any ideas? Or maybe more right and efficient way? Many thanks!
I've changed query and it works fine now. If anyone need:
$threads = Thread::latest('updated_at')
->join('participants as part', 'part.thread_id', '=', 'threads.id')
->join('admins', function($join) use($q, $userId) {
//filter rows of my own
$join->on('admins.id', '=', 'part.user_id')
->where('admins.id', '<>', $userId);
})
//search by firstName,lastName or email
->where('admins.lastName', 'LIKE', '%'.$q.'%')
->orWhere('admins.firstName', 'LIKE', '%'.$q.'%')
->orWhere('admins.email', 'LIKE', '%'.$q.'%')
->with(['participants' => function($query) {
$query->with('user');
}])
->distinct()
->forUser($userId)
->paginate($limit)
;
Please or to participate in this conversation.