Skip to content

Commit dca2338

Browse files
committed
Merge pull request #4 from anhskohbo/tweak-cs
Tweak Some Code
2 parents 2c9757e + b2f9d9f commit dca2338

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/Cmgmyr/Messenger/Models/Message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php namespace Cmgmyr\Messenger\Models;
22

3-
use Illuminate\Database\Eloquent\Model as Eloquent;
43
use Illuminate\Support\Facades\Config;
4+
use Illuminate\Database\Eloquent\Model as Eloquent;
55

66
class Message extends Eloquent
77
{

src/Cmgmyr/Messenger/Models/Participant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php namespace Cmgmyr\Messenger\Models;
22

3+
use Illuminate\Support\Facades\Config;
34
use Illuminate\Database\Eloquent\Model as Eloquent;
45
use Illuminate\Database\Eloquent\SoftDeletingTrait;
5-
use Illuminate\Support\Facades\Config;
66

77
class Participant extends Eloquent
88
{

src/Cmgmyr/Messenger/Models/Thread.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Carbon\Carbon;
44
use Illuminate\Database\Eloquent\Model as Eloquent;
5+
use Illuminate\Database\Eloquent\ModelNotFoundException;
56

67
class 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

src/Cmgmyr/Messenger/Traits/Messagable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php namespace Cmgmyr\Messenger\Traits;
22

3+
use Cmgmyr\Messenger\Models\Thread;
4+
use Cmgmyr\Messenger\Models\Participant;
5+
36
trait 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]) {

0 commit comments

Comments
 (0)