File tree Expand file tree Collapse file tree 4 files changed +10
-6
lines changed
Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 11<?php namespace Cmgmyr \Messenger \Models ;
22
3- use Illuminate \Database \Eloquent \Model as Eloquent ;
43use Illuminate \Support \Facades \Config ;
4+ use Illuminate \Database \Eloquent \Model as Eloquent ;
55
66class Message extends Eloquent
77{
Original file line number Diff line number Diff line change 11<?php namespace Cmgmyr \Messenger \Models ;
22
3+ use Illuminate \Support \Facades \Config ;
34use Illuminate \Database \Eloquent \Model as Eloquent ;
45use Illuminate \Database \Eloquent \SoftDeletingTrait ;
5- use Illuminate \Support \Facades \Config ;
66
77class Participant extends Eloquent
88{
Original file line number Diff line number Diff line change 22
33use Carbon \Carbon ;
44use Illuminate \Database \Eloquent \Model as Eloquent ;
5+ use Illuminate \Database \Eloquent \ModelNotFoundException ;
56
67class Thread extends Eloquent
78{
@@ -140,7 +141,7 @@ public function markAsRead($userId)
140141 $ participant = $ this ->getParticipantFromUser ($ userId );
141142 $ participant ->last_read = new Carbon ;
142143 $ participant ->save ();
143- } catch (\ Illuminate \ Database \ Eloquent \ ModelNotFoundException $ e ) {
144+ } catch (ModelNotFoundException $ e ) {
144145 // do nothing
145146 }
146147 }
@@ -158,7 +159,7 @@ public function isUnread($userId)
158159 if ($ this ->updated_at > $ participant ->last_read ) {
159160 return true ;
160161 }
161- } catch (\ Illuminate \ Database \ Eloquent \ ModelNotFoundException $ e ) {
162+ } catch (ModelNotFoundException $ e ) {
162163 // do nothing
163164 }
164165
Original file line number Diff line number Diff line change 11<?php namespace Cmgmyr \Messenger \Traits ;
22
3+ use Cmgmyr \Messenger \Models \Thread ;
4+ use Cmgmyr \Messenger \Models \Participant ;
5+
36trait Messagable
47{
58 /**
@@ -40,10 +43,10 @@ public function newMessagesCount()
4043 public function threadsWithNewMessages ()
4144 {
4245 $ threadsWithNewMessages = [];
43- $ participants = \ Cmgmyr \ Messenger \ Models \ Participant::where ('user_id ' , $ this ->id )->lists ('last_read ' , 'thread_id ' );
46+ $ participants = Participant::where ('user_id ' , $ this ->id )->lists ('last_read ' , 'thread_id ' );
4447
4548 if ($ participants ) {
46- $ threads = \ Cmgmyr \ Messenger \ Models \ Thread::whereIn ('id ' , array_keys ($ participants ))->get ();
49+ $ threads = Thread::whereIn ('id ' , array_keys ($ participants ))->get ();
4750
4851 foreach ($ threads as $ thread ) {
4952 if ($ thread ->updated_at > $ participants [$ thread ->id ]) {
You can’t perform that action at this time.
0 commit comments