NotifyOfNewTechTipComment   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 6
c 1
b 0
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 1
1
<?php
2
3
namespace App\Listeners\Notify;
4
5
use App\Events\TechTips\TechTipCommentCreatedEvent;
6
use App\Models\TechTip;
7
use App\Models\User;
8
use App\Models\UserTechTipBookmark;
9
use App\Notifications\NewTechTipCommentNotification;
10
use Illuminate\Contracts\Queue\ShouldQueue;
11
use Illuminate\Queue\InteractsWithQueue;
12
use Illuminate\Support\Facades\Auth;
13
use Illuminate\Support\Facades\Notification;
14
15
class NotifyOfNewTechTipComment implements ShouldQueue
16
{
17
    /**
18
     * Handle the event
19
     */
20
    public function handle(TechTipCommentCreatedEvent $event)
21
    {
22
        $userList = [];
23
24
        $userList[] = TechTip::find($event->comment->tip_id)->first()->user_id;
25
        $bookmarks  = UserTechTipBookmark::where('tip_id', $event->comment->tip_id)->get()->toArray();
26
27
        $userList = User::find(array_merge($userList, $bookmarks));
28
        Notification::send($userList, new NewTechTipCommentNotification($event->comment, Auth::user()));
29
    }
30
}
31