Passed
Branch dev5a (b4693d)
by Ron
27:36
created

UserNotifications   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 10
cp 0
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
    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