|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
|
6
|
|
|
|
|
7
|
|
|
use Illuminate\Support\Facades\Auth; |
|
8
|
|
|
|
|
9
|
|
|
use App\Domains\User\GetUserStats; |
|
10
|
|
|
use App\Domains\User\UserNotifications; |
|
11
|
|
|
use App\Domains\TechTips\GetTechTipStats; |
|
12
|
|
|
|
|
13
|
|
|
class DashboardController extends Controller |
|
14
|
|
|
{ |
|
15
|
|
|
// Home page for authorized users |
|
16
|
2 |
|
public function index() |
|
17
|
|
|
{ |
|
18
|
2 |
|
$userObj = new GetUserStats(Auth::user()->user_id); |
|
19
|
2 |
|
$tipsObj = new GetTechTipStats; |
|
20
|
|
|
|
|
21
|
2 |
|
return view('dashboard', [ |
|
22
|
2 |
|
'custFavs' => $userObj->getUserCustomerFavs(), |
|
23
|
2 |
|
'tipFavs' => $userObj->getUserTipFavs(), |
|
24
|
2 |
|
'tips30' => $tipsObj->getTipsInLastDays(), |
|
25
|
2 |
|
'tipsAll' => $tipsObj->getTotalTipsCount(), |
|
26
|
2 |
|
'linksActive' => $userObj->getUserActiveLinks(), |
|
27
|
2 |
|
'linksTotal' => $userObj->getUserTotalLinks(), |
|
28
|
|
|
]); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
// Retrieve all users notifications |
|
32
|
2 |
|
public function getNotifications() |
|
33
|
|
|
{ |
|
34
|
2 |
|
return Auth::user()->notifications; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
// Mark a notification as read |
|
38
|
2 |
|
public function markNotification($id) |
|
39
|
|
|
{ |
|
40
|
2 |
|
(new UserNotifications)->markNotificationRead($id); |
|
41
|
|
|
|
|
42
|
2 |
|
return response()->json(['success' => true]); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
// Delete a notification |
|
46
|
2 |
|
public function delNotification($id) |
|
47
|
|
|
{ |
|
48
|
2 |
|
(new UserNotifications)->deleteNotification($id); |
|
49
|
|
|
|
|
50
|
2 |
|
return response()->json(['success' => true]); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|