Passed
Push — master ( f51c1b...16736d )
by Arthur
05:36
created

NotificationController::allUnread()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 14.10.18
6
 * Time: 18:58.
7
 */
8
9
namespace Modules\Notification\Http\Controllers;
10
11
use Illuminate\Routing\Controller;
12
use Modules\Notification\Contracts\NotificationServiceContract;
13
use Modules\Notification\Resources\NotificationResource;
14
15
class NotificationController extends Controller
16
{
17
    protected $service;
18
19
    /**
20
     * NotificationController constructor.
21
     * @param $service
22
     */
23
    public function __construct(NotificationServiceContract $service)
24
    {
25
        $this->service = $service;
26
    }
27
28
    public function all()
29
    {
30
        return NotificationResource::collection($this->service->allNotificationsByUser(get_authenticated_user()));
31
    }
32
33
    public function allUnread()
34
    {
35
        return NotificationResource::collection($this->service->unreadNotifcationsByUser(get_authenticated_user()));
36
    }
37
38
    public function read($id)
39
    {
40
        $this->service->markAsRead($id);
41
42
        return response()->json([
43
            'success',
44
        ]);
45
    }
46
47
    public function unread($id)
48
    {
49
        $this->service->markAsUnread($id);
50
51
        return response()->json([
52
            'success',
53
        ]);
54
    }
55
}
56