Passed
Push — dev5 ( 67c7cf...c7611f )
by Ron
19:22
created

DashboardController::about()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Support\Facades\Auth;
6
7
use App\Domains\Users\GetUserStats;
8
use App\Domains\Users\UserNotifications;
9
use App\Domains\TechTips\GetTechTipStats;
10
11
class DashboardController extends Controller
12
{
13
    public function __construct()
14
    {
15
        //  Only authorized users have access to these pages
16
        $this->middleware('auth');
17
    }
18
19
    //  Dashboard is the Logged In User home landing page
20
    public function index()
21
    {
22
        $userStats = new GetUserStats;
23
        $tipStats  = new GetTechTipStats;
24
25
        return view('dashboard', [
26
            'custFavs'    => $userStats->getUserCustomerFavs(),
27
            'tipFavs'     => $userStats->getUserTechTipFavs(),
28
            'tips30'      => $tipStats->getTipsInLastDays(30),
29
            'tipsAll'     => $tipStats->getTotalTechTipCount(),
30
            'activeLinks' => $userStats->getUserActiveFileLinks(),
31
            'totalLinks'  => $userStats->getUserTotalLinks(),
32
        ]);
33
    }
34
35
    //  Get the users notifications
36
    public function getNotifications()
37
    {
38
        return Auth::user()->notifications;
39
    }
40
41
    //  Mark a notification as read
42
    public function markNotification($id)
43
    {
44
        (new UserNotifications)->markNotificationRead($id);
45
46
        return response()->json(['success' => true]);
47
    }
48
49
    //  Delte a user notification
50
    public function delNotification($id)
51
    {
52
        (new UserNotifications)->deleteNotification($id);
53
54
        return response()->json(['success' => true]);
55
    }
56
}
57