Passed
Push — master ( 1d6d9a...2a90e7 )
by Ron
02:47 queued 12s
created

MarkUserNotifications::deleteNotification()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.008

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 4
cts 5
cp 0.8
crap 1.008
rs 10
1
<?php
2
3
namespace App\Domains\Users;
4
5
use Illuminate\Support\Facades\Auth;
6
use Illuminate\Support\Facades\Log;
7
8
class MarkUserNotifications
9
{
10 4
    public function markNotificationRead($id)
11
    {
12 4
        $notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first();
13 4
        Log::debug('Marked user notification as read for '.Auth::user()->full_name.'. Data - ', array($notification));
14 4
        $notification->markAsRead();
15
16
        return true;
17
    }
18
19 4
    public function deleteNotification($id)
20
    {
21 4
        $notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first();
22 4
        Log::debug('Deleted user notification for '.Auth::user()->full_name.'. Data - ', array($notification));
23 4
        $notification->delete();
24
25
        return true;
26
    }
27
28
}
29