Passed
Push — dev5a ( c41270...352680 )
by Ron
07:09
created

UserNotifications::markNotificationRead()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

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 5
cts 5
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Domains\User;
4
5
use Illuminate\Support\Facades\Auth;
6
use Illuminate\Support\Facades\Log;
7
8
9
class UserNotifications
10
{
11 4
    public function markNotificationRead($id)
12
    {
13 4
        $notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first();
14 4
        Log::debug('Marked user notification as read for '.Auth::user()->full_name.'. Data - ', array($notification));
15 4
        $notification->markAsRead();
16
17 4
        return true;
18
    }
19
20 4
    public function deleteNotification($id)
21
    {
22 4
        $notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first();
23 4
        Log::debug('Deleted user notification for '.Auth::user()->full_name.'. Data - ', array($notification));
24 4
        $notification->delete();
25
26 4
        return true;
27
    }
28
}
29