Browse Source

Merge pull request #432 from 1day2die/readall_button_notifications

Added read all Button for Notifications
Dennis 3 years ago
parent
commit
ce159e9cd6

+ 9 - 6
app/Http/Controllers/NotificationController.php

@@ -2,11 +2,6 @@
 
 
 namespace App\Http\Controllers;
 namespace App\Http\Controllers;
 
 
-use Illuminate\Contracts\View\Factory;
-use Illuminate\Contracts\View\View;
-use Illuminate\Http\Request;
-use Illuminate\Http\Response;
-use Illuminate\Notifications\Notification;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Auth;
 
 
 class NotificationController extends Controller
 class NotificationController extends Controller
@@ -15,7 +10,6 @@ class NotificationController extends Controller
     public function index()
     public function index()
     {
     {
         $notifications = Auth::user()->notifications()->paginate();
         $notifications = Auth::user()->notifications()->paginate();
-
         return view('notifications.index')->with([
         return view('notifications.index')->with([
             'notifications' => $notifications
             'notifications' => $notifications
         ]);
         ]);
@@ -31,4 +25,13 @@ class NotificationController extends Controller
             'notification' => $notification
             'notification' => $notification
         ]);
         ]);
     }
     }
+
+    public function readAll(){
+        $notifications = Auth::user()->notifications()->get();
+        foreach($notifications as $notification){
+            $notification->markAsRead();
+        }
+        return redirect()->back();
+
+    }
 }
 }

+ 1 - 1
config/app.php

@@ -4,7 +4,7 @@ use App\Models\Settings;
 
 
 return [
 return [
 
 
-    'version' => '0.7.5',
+    'version' => '0.7.6',
 
 
     /*
     /*
     |--------------------------------------------------------------------------
     |--------------------------------------------------------------------------

+ 3 - 0
resources/views/layouts/main.blade.php

@@ -112,6 +112,9 @@
                         <div class="dropdown-divider"></div>
                         <div class="dropdown-divider"></div>
                         <a href="{{ route('notifications.index') }}"
                         <a href="{{ route('notifications.index') }}"
                             class="dropdown-item dropdown-footer">{{ __('See all Notifications') }}</a>
                             class="dropdown-item dropdown-footer">{{ __('See all Notifications') }}</a>
+                        <div class="dropdown-divider"></div>
+                        <a href="{{ route('notifications.readAll') }}"
+                           class="dropdown-item dropdown-footer">{{ __('Mark all as read') }}</a>
                     </div>
                     </div>
                 </li>
                 </li>
 
 

+ 4 - 0
resources/views/notifications/index.blade.php

@@ -29,6 +29,10 @@
                 <div class="col-md-8">
                 <div class="col-md-8">
                     <p>{{__('All notifications')}}</p>
                     <p>{{__('All notifications')}}</p>
                 </div>
                 </div>
+                    <a class="float-right">
+                        <a href="{{route('notifications.readAll')}}"><button class="btn btn-info btn-xs">{{__('Mark all as read')}}</button></a>
+
+
                 @foreach($notifications as $notification)
                 @foreach($notifications as $notification)
                     <div class="col-md-8">
                     <div class="col-md-8">
                         <div class="card">
                         <div class="card">

+ 1 - 0
routes/web.php

@@ -58,6 +58,7 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
     })->middleware(['auth', 'throttle:3,1'])->name('verification.send');
     })->middleware(['auth', 'throttle:3,1'])->name('verification.send');
 
 
     #normal routes
     #normal routes
+    Route::get('notifications/readAll',[NotificationController::class,'readAll'])->name('notifications.readAll');
     Route::resource('notifications', NotificationController::class);
     Route::resource('notifications', NotificationController::class);
     Route::resource('servers', ServerController::class);
     Route::resource('servers', ServerController::class);
     Route::resource('profile', ProfileController::class);
     Route::resource('profile', ProfileController::class);