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