Completed
Push — develop ( 1c7ff0...b15f7e )
by Neil
08:15
created

NotificationController::index()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 18
rs 9.4285
cc 2
eloc 11
nc 2
nop 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Dingo\Api\Http;
6
use Dingo\Api\Routing\Helpers;
7
use Illuminate\Http\Request;
8
9
class NotificationController extends Controller
10
{
11
    use Helpers;
12
13
    /**
14
     * Constructor
15
     */
16
    public function __construct() {
17
        $this->middleware('auth');
18
    }
19
20
    /**
21
     * Display a listing of the resource.
22
     *
23
     * @return \Illuminate\Http\Response
24
     */
25
    public function index($type = null)
26
    {
27
28
        $notifications = $this->api->be(auth()->user())->get('/api/notifications/'.$type);
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
        if ($type === 'archive')
30
        {
31
            $page   = '';
32
            $button = ' notifications';
33
            $bg     = 'maroon';
34
        }
35
        else {
36
            $page   = 'archive';
37
            $button = ' archive';
38
            $bg     = 'blue';
39
        }
40
41
        return view('notifications.list', ['notifications' => $notifications, 'page' => $page, 'button' => $button, 'bg' => $bg, "type" => $type]);
42
    }
43
44
    public function update($id, $action)
45
    {
46
47
        return response()->json($this->api->be(auth()->user())->patch('/api/notifications/'.$id.'/'.$action));
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
    }
49
50
}
51