Thread   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A participant() 0 4 1
A participateBy() 0 7 1
A scopeRecent() 0 4 1
1
<?php
2
3
namespace Transmissor\Models\Messenger;
4
5
use Auth;
6
use Cmgmyr\Messenger\Models\Thread as MessengerThread;
7
8
class Thread extends MessengerThread
9
{
10
    public function participant()
11
    {
12
        return $this->participants()->where('actorable_type', '=', User::class)->where('actorable_id', '!=', Auth::id())->first()->user;
13
    }
14
15
    public static function participateBy($user_id)
0 ignored issues
show
Unused Code introduced by
The parameter $user_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
    {
17
        $user_id = Auth::id();
18
        $thread_ids = array_unique(Participant::byWhom($user_id)->pluck('messageable_id')->toArray());
0 ignored issues
show
Bug introduced by
The method byWhom() does not exist on Transmissor\Models\Messenger\Participant. Did you maybe mean scopeByWhom()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
19
20
        return Thread::whereIn('id', $thread_ids)->orderBy('updated_at', 'desc')->paginate(15);
21
    }
22
23
    public function scopeRecent($query)
24
    {
25
        return $query->orderBy('created_at', 'desc');
26
    }
27
}
28