1 | <?php |
||
2 | |||
3 | namespace App\Http\Controllers; |
||
4 | |||
5 | use Illuminate\Http\Request; |
||
6 | use Illuminate\Support\Facades\Auth; |
||
7 | use Illuminate\Support\Facades\Log; |
||
8 | use App\CustomerFavs; |
||
9 | use App\TechTipFavs; |
||
10 | |||
11 | class DashboardController extends Controller |
||
12 | { |
||
13 | public function __construct() |
||
14 | { |
||
15 | $this->middleware('auth'); |
||
16 | } |
||
17 | |||
18 | // Dashboard is the Logged In User home landing page |
||
19 | public function index() |
||
20 | { |
||
21 | // Get the users notifications |
||
22 | $notifications = Auth::user()->unreadNotifications; |
||
1 ignored issue
–
show
|
|||
23 | |||
24 | // Get the users Customer bookmarks |
||
25 | $custFavs = CustomerFavs::where('user_id', Auth::user()->user_id) |
||
26 | ->LeftJoin('customers', 'customer_favs.cust_id', '=', 'customers.cust_id') |
||
27 | ->get(); |
||
28 | // Get the users Tech Tip bookmarks |
||
29 | $tipFavs = TechTipFavs::where('tech_tip_favs.user_id', Auth::user()->user_id) |
||
30 | ->LeftJoin('tech_tips', 'tech_tips.tip_id', '=', 'tech_tip_favs.tip_id') |
||
31 | ->get(); |
||
32 | |||
33 | return view('dashboard', [ |
||
34 | 'custFavs' => $custFavs, |
||
35 | 'tipFavs' => $tipFavs, |
||
36 | 'notifications' => $notifications |
||
37 | ]); |
||
38 | } |
||
39 | |||
40 | public function markNotification($id) |
||
41 | { |
||
42 | $notification = Auth::user()->notifications()->where('id', $id)->first(); |
||
43 | if($notification) |
||
44 | { |
||
45 | $notification->delete(); |
||
46 | Log::info('Notification ID-'.$id.' deleted for User ID-'.Auth::user()->user_id); |
||
47 | } |
||
48 | else |
||
49 | { |
||
50 | Log::notice('Notification ID-'.$id.' not found for user ID-'.Auth::user()->user_id); |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.