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

UserNotifications   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A markNotificationRead() 0 7 1
A deleteNotification() 0 7 1
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