From c49919bc6f6fac58f767abb0c247e455d6599f52 Mon Sep 17 00:00:00 2001 From: a-komarev Date: Sat, 16 Sep 2017 02:12:51 +0300 Subject: [PATCH] Fix threadsWithNewMessages docblock and typehint Eloquent Builder inside method --- src/Traits/Messagable.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Traits/Messagable.php b/src/Traits/Messagable.php index c485ec2..9ef181d 100644 --- a/src/Traits/Messagable.php +++ b/src/Traits/Messagable.php @@ -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 { @@ -36,7 +37,7 @@ public function participants() /** * Thread relationship. * - * @return \Illuminate\Database\Eloquent\Relations\belongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * * @codeCoverageIgnore */ @@ -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();