|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Module; |
|
|
|
|
|
|
6
|
|
|
use App\TechTipFavs; |
|
7
|
|
|
use App\CustomerFavs; |
|
8
|
|
|
use Illuminate\Http\Request; |
|
9
|
|
|
use Illuminate\Support\Facades\Log; |
|
10
|
|
|
use Illuminate\Support\Facades\Auth; |
|
11
|
|
|
use Illuminate\Support\Facades\Gate; |
|
12
|
|
|
|
|
13
|
|
|
use Zip; |
|
14
|
|
|
use Carbon\Carbon; |
|
15
|
|
|
|
|
16
|
|
|
//use Nwidart\Modules; |
|
17
|
|
|
use Mail; |
|
18
|
|
|
use App\Mail\InitializeUser; |
|
19
|
|
|
|
|
20
|
|
|
use App\TechTips; |
|
21
|
|
|
use App\FileLinks; |
|
22
|
|
|
// use Carbon\Carbon; |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
class DashboardController extends Controller |
|
28
|
|
|
{ |
|
29
|
|
|
public function __construct() |
|
30
|
|
|
{ |
|
31
|
|
|
// Only authorized users have access to these pages |
|
32
|
|
|
$this->middleware('auth'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
// Dashboard is the Logged In User home landing page |
|
36
|
|
|
public function index() |
|
37
|
|
|
{ |
|
38
|
|
|
// Get the users Customer bookmarks |
|
39
|
|
|
// $custFavs = CustomerFavs::where('user_id', Auth::user()->user_id) |
|
40
|
|
|
// ->LeftJoin('customers', 'customer_favs.cust_id', '=', 'customers.cust_id') |
|
41
|
|
|
// ->get(); |
|
42
|
|
|
// // Get the users Tech Tip bookmarks |
|
43
|
|
|
// $tipFavs = TechTipFavs::where('tech_tip_favs.user_id', Auth::user()->user_id) |
|
44
|
|
|
// ->LeftJoin('tech_tips', 'tech_tips.tip_id', '=', 'tech_tip_favs.tip_id') |
|
45
|
|
|
// ->get(); |
|
46
|
|
|
|
|
47
|
|
|
$custFavs = CustomerFavs::where('user_id', Auth::user()->user_id)->with('Customers')->get(); |
|
48
|
|
|
$tipFavs = TechTipFavs::where('user_id', Auth::user()->user_id)->with('TechTips')->get(); |
|
49
|
|
|
$tips30Days = TechTips::where('created_at', '>', Carbon::now()->subDays(30))->count(); |
|
50
|
|
|
$tipsTotal = TechTips::all()->count(); |
|
51
|
|
|
$activeLinks = FileLinks::where('user_id', Auth::user()->user_id)->where('expire', '>', Carbon::now())->count(); |
|
52
|
|
|
$totalLinks = FileLinks::where('user_id', Auth::user()->user_id)->count(); |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
// return $tipFavs; |
|
56
|
|
|
|
|
57
|
|
|
return view('dashboard', [ |
|
58
|
|
|
'custFavs' => $custFavs, |
|
59
|
|
|
'tipFavs' => $tipFavs, |
|
60
|
|
|
'tips30' => $tips30Days, |
|
61
|
|
|
'tipsAll' => $tipsTotal, |
|
62
|
|
|
'activeLinks' => $activeLinks, |
|
63
|
|
|
'totalLinks' => $totalLinks, |
|
64
|
|
|
// 'notifications' => $notifications->toArray(), |
|
65
|
|
|
// 'modules' => $modules |
|
66
|
|
|
]); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
// About page |
|
70
|
|
|
public function about() |
|
71
|
|
|
{ |
|
72
|
|
|
exec('git symbolic-ref HEAD', $output); |
|
73
|
|
|
$t = explode('/', $output[0]); |
|
74
|
|
|
$branch = end($t) === 'master' ? 'latest' : end($t); |
|
75
|
|
|
|
|
76
|
|
|
return view('about', [ |
|
77
|
|
|
'branch' => $branch |
|
78
|
|
|
]); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
// Get the users notifications |
|
82
|
|
|
public function getNotifications() |
|
83
|
|
|
{ |
|
84
|
|
|
return Auth::user()->notifications; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
// Mark a notification as read |
|
88
|
|
|
public function markNotification($id) |
|
89
|
|
|
{ |
|
90
|
|
|
$notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first(); |
|
91
|
|
|
if(!$notification) |
|
92
|
|
|
{ |
|
93
|
|
|
return abort(404); |
|
|
|
|
|
|
94
|
|
|
} |
|
95
|
|
|
$notification->markAsRead(); |
|
96
|
|
|
|
|
97
|
|
|
return response()->json(['success' => true]); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
// Deelte a user notification |
|
101
|
|
|
public function delNotification($id) |
|
102
|
|
|
{ |
|
103
|
|
|
$notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first(); |
|
104
|
|
|
if($notification) |
|
105
|
|
|
{ |
|
106
|
|
|
$notification->delete(); |
|
107
|
|
|
Log::info('Notification ID-'.$id.' deleted for User ID-'.Auth::user()->user_id); |
|
108
|
|
|
} |
|
109
|
|
|
else |
|
110
|
|
|
{ |
|
111
|
|
|
return abort(404); |
|
|
|
|
|
|
112
|
|
|
Log::notice('Notification ID-'.$id.' not found for user ID-'.Auth::user()->user_id); |
|
|
|
|
|
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
return response()->json(['success' => true]); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths