Passed
Branch dev5a (b4693d)
by Ron
27:36
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 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 0
cts 5
cp 0
crap 2
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
    public function markNotificationRead($id)
12
    {
13
        $notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first();
14
        Log::debug('Marked user notification as read for '.Auth::user()->full_name.'. Data - ', array($notification));
15
        $notification->markAsRead();
16
17
        return true;
18
    }
19
20
    public function deleteNotification($id)
21
    {
22
        $notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first();
23
        Log::debug('Deleted user notification for '.Auth::user()->full_name.'. Data - ', array($notification));
24
        $notification->delete();
25
26
        return true;
27
    }
28
}
29