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
|
|
|
|