Skip to content

Commit

Permalink
Merge pull request #252 from cybercog/meta/messagable-docblocks-fix
Browse files Browse the repository at this point in the history
Fix threadsWithNewMessages docblock
  • Loading branch information
cmgmyr authored Sep 18, 2017
2 parents 893d1b5 + c49919b commit c90466e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Traits/Messagable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Cmgmyr\Messenger\Models\Models;
use Cmgmyr\Messenger\Models\Participant;
use Cmgmyr\Messenger\Models\Thread;
use Illuminate\Database\Eloquent\Builder;

trait Messagable
{
Expand Down Expand Up @@ -36,7 +37,7 @@ public function participants()
/**
* Thread relationship.
*
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*
* @codeCoverageIgnore
*/
Expand Down Expand Up @@ -73,12 +74,12 @@ public function unreadMessagesCount()
/**
* Returns all threads with new messages.
*
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
* @return \Illuminate\Database\Eloquent\Collection
*/
public function threadsWithNewMessages()
{
return $this->threads()
->where(function ($q) {
->where(function (Builder $q) {
$q->whereNull(Models::table('participants') . '.last_read');
$q->orWhere(Models::table('threads') . '.updated_at', '>', $this->getConnection()->raw($this->getConnection()->getTablePrefix() . Models::table('participants') . '.last_read'));
})->get();
Expand Down

0 comments on commit c90466e

Please sign in to comment.