Skip to content

Commit

Permalink
Update NotificationController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
punkestu authored Oct 31, 2024
1 parent 86a9786 commit 5d27355
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/Http/Controllers/NotificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ class NotificationController extends Controller
{
public function index()
{
$notifications = auth()->user()->profile->cabang ? auth()->user()->profile->cabang->notifications : [];
Notification::where('to', auth()->user()->profile->cabang->id)->update(['is_read' => true]);
if(auth()->user()->profile->cabang) {
$notifications = auth()->user()->profile->cabang->notifications;
Notification::where('to', auth()->user()->profile->cabang->id)->update(['is_read' => true]);
} else {
$notifications = [];
}
return view('notification.index', compact('notifications'));
}
}

0 comments on commit 5d27355

Please sign in to comment.