Thread::participateBy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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