|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Module; |
|
|
|
|
|
|
6
|
|
|
use App\TechTips; |
|
7
|
|
|
use App\FileLinks; |
|
8
|
|
|
use Carbon\Carbon; |
|
9
|
|
|
use App\TechTipFavs; |
|
10
|
|
|
use App\CustomerFavs; |
|
11
|
|
|
use Illuminate\Support\Facades\Log; |
|
12
|
|
|
use Illuminate\Support\Facades\Auth; |
|
13
|
|
|
|
|
14
|
|
|
class DashboardController extends Controller |
|
15
|
|
|
{ |
|
16
|
20 |
|
public function __construct() |
|
17
|
|
|
{ |
|
18
|
|
|
// Only authorized users have access to these pages |
|
19
|
20 |
|
$this->middleware('auth'); |
|
20
|
20 |
|
} |
|
21
|
|
|
|
|
22
|
|
|
// Dashboard is the Logged In User home landing page |
|
23
|
2 |
|
public function index() |
|
24
|
|
|
{ |
|
25
|
2 |
|
$custFavs = CustomerFavs::where('user_id', Auth::user()->user_id)->with('Customers')->get(); |
|
26
|
2 |
|
$tipFavs = TechTipFavs::where('user_id', Auth::user()->user_id)->with('TechTips')->get(); |
|
27
|
2 |
|
$tips30Days = TechTips::where('created_at', '>', Carbon::now()->subDays(30))->count(); |
|
28
|
2 |
|
$tipsTotal = TechTips::all()->count(); |
|
29
|
2 |
|
$activeLinks = FileLinks::where('user_id', Auth::user()->user_id)->where('expire', '>', Carbon::now())->count(); |
|
30
|
2 |
|
$totalLinks = FileLinks::where('user_id', Auth::user()->user_id)->count(); |
|
31
|
|
|
|
|
32
|
2 |
|
return view('dashboard', [ |
|
33
|
2 |
|
'custFavs' => $custFavs, |
|
34
|
2 |
|
'tipFavs' => $tipFavs, |
|
35
|
2 |
|
'tips30' => $tips30Days, |
|
36
|
2 |
|
'tipsAll' => $tipsTotal, |
|
37
|
2 |
|
'activeLinks' => $activeLinks, |
|
38
|
2 |
|
'totalLinks' => $totalLinks, |
|
39
|
|
|
// 'modules' => $modules |
|
40
|
|
|
]); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
// About page |
|
44
|
|
|
public function about() |
|
45
|
|
|
{ |
|
46
|
|
|
exec('git symbolic-ref HEAD', $output); |
|
47
|
|
|
$t = explode('/', $output[0]); |
|
48
|
|
|
$branch = end($t) === 'master' ? 'latest' : end($t); |
|
49
|
|
|
|
|
50
|
|
|
return view('about', [ |
|
51
|
|
|
'branch' => $branch |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
// Get the users notifications |
|
56
|
|
|
public function getNotifications() |
|
57
|
|
|
{ |
|
58
|
|
|
return Auth::user()->notifications; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
// Mark a notification as read |
|
62
|
4 |
|
public function markNotification($id) |
|
63
|
|
|
{ |
|
64
|
4 |
|
$notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first(); |
|
65
|
4 |
|
if(!$notification) |
|
66
|
|
|
{ |
|
67
|
4 |
|
return abort(404); |
|
68
|
|
|
} |
|
69
|
|
|
$notification->markAsRead(); |
|
70
|
|
|
|
|
71
|
|
|
return response()->json(['success' => true]); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
// Deelte a user notification |
|
75
|
4 |
|
public function delNotification($id) |
|
76
|
|
|
{ |
|
77
|
4 |
|
$notification = Auth::user()->notifications()->where('id', $id)->where('notifiable_id', Auth::user()->user_id)->first(); |
|
78
|
4 |
|
if($notification) |
|
79
|
|
|
{ |
|
80
|
|
|
$notification->delete(); |
|
81
|
|
|
Log::info('Notification ID-'.$id.' deleted for User ID-'.Auth::user()->user_id); |
|
82
|
|
|
} |
|
83
|
|
|
else |
|
84
|
|
|
{ |
|
85
|
4 |
|
Log::notice('Notification ID-'.$id.' not found for user ID-'.Auth::user()->user_id); |
|
86
|
4 |
|
return abort(404); |
|
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
return response()->json(['success' => true]); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
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