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\TechTips\GetTechTipStats; |
9
|
|
|
use App\Domains\Users\MarkUserNotifications; |
10
|
|
|
|
11
|
|
|
class DashboardController extends Controller |
12
|
|
|
{ |
13
|
22 |
|
public function __construct() |
14
|
|
|
{ |
15
|
|
|
// Only authorized users have access to these pages |
16
|
22 |
|
$this->middleware('auth'); |
17
|
22 |
|
} |
18
|
|
|
|
19
|
|
|
// Dashboard is the Logged In User home landing page |
20
|
2 |
|
public function index() |
21
|
|
|
{ |
22
|
2 |
|
$userStats = new GetUserStats; |
23
|
2 |
|
$tipStats = new GetTechTipStats; |
24
|
|
|
|
25
|
2 |
|
return view('dashboard', [ |
26
|
2 |
|
'custFavs' => $userStats->getUserCustomerFavs(), |
27
|
2 |
|
'tipFavs' => $userStats->getUserTechTipFavs(), |
28
|
2 |
|
'tips30' => $tipStats->getTipsInLastDays(30), |
29
|
2 |
|
'tipsAll' => $tipStats->getTotalTechTipCount(), |
30
|
2 |
|
'activeLinks' => $userStats->getUserActiveFileLinks(), |
31
|
2 |
|
'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
|
4 |
|
public function markNotification($id) |
43
|
|
|
{ |
44
|
4 |
|
(new MarkUserNotifications)->markNotificationRead($id); |
45
|
|
|
|
46
|
|
|
return response()->json(['success' => true]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
// Delte a user notification |
50
|
4 |
|
public function delNotification($id) |
51
|
|
|
{ |
52
|
4 |
|
(new MarkUserNotifications)->deleteNotification($id); |
53
|
|
|
|
54
|
|
|
return response()->json(['success' => true]); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
// About page |
58
|
2 |
|
public function about() |
59
|
|
|
{ |
60
|
2 |
|
return view('about'); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|