Passed
Push — dev5 ( 125e24...928bc2 )
by Ron
09:11
created

UserNotifications::deleteNotification()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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