Jovan Jovanovic пре 3 година
родитељ
комит
916fbad8af

+ 3 - 31
app/Http/Controllers/Api/NotificationController.php

@@ -12,7 +12,7 @@ use Illuminate\Http\Request;
 class NotificationController extends Controller
 class NotificationController extends Controller
 {
 {
     /**
     /**
-     * Displays all notifications of an user.
+     * Display all notifications of an user.
      * @param Request $request
      * @param Request $request
      * @param int $userId
      * @param int $userId
      * @return Response
      * @return Response
@@ -26,7 +26,7 @@ class NotificationController extends Controller
     }
     }
 
 
     /**
     /**
-     * Displays a specific notification
+     * Display a specific notification
      * 
      * 
      * @param int $userId
      * @param int $userId
      * @param int $notificationId
      * @param int $notificationId
@@ -45,19 +45,6 @@ class NotificationController extends Controller
 
 
         return $notification;
         return $notification;
     }
     }
-    /**
-     * Shows all unread notifications of an user.
-     * @param Request $request
-     * @param int $userId
-     * @return Response
-     */
-    public function indexUnread(Request $request, int $userId)
-    {
-        $discordUser = DiscordUser::find($userId);
-        $user = $discordUser ? $discordUser->user : User::findOrFail($userId);
-
-        return $user->unreadNotifications()->paginate($request->query("per_page", 50));
-    }
 
 
     /**
     /**
      * Send a notification to an user.
      * Send a notification to an user.
@@ -99,24 +86,9 @@ class NotificationController extends Controller
         return response()->json(["message" => "All notifications have been successfully deleted.", "count" => $count]);
         return response()->json(["message" => "All notifications have been successfully deleted.", "count" => $count]);
     }
     }
 
 
-    /**
-     * Delete all read notifications from an user
-     * 
-     * @param int $userId
-     * @return JsonResponse
-     */
-    public function deleteRead(int $userId)
-    {
-        $discordUser = DiscordUser::find($userId);
-        $user = $discordUser ? $discordUser->user : User::findOrFail($userId);
-
-        $count = $user->notifications()->whereNotNull("read_at")->delete();
-
-        return response()->json(["message" => "All read notifications have been successfully deleted.", "count" => $count]);
-    }
 
 
     /**
     /**
-     * Deletes a specific notification
+     * Delete a specific notification
      * 
      * 
      * @param int $userId
      * @param int $userId
      * @param int $notificationId
      * @param int $notificationId

+ 3 - 2
app/Http/Controllers/Api/VoucherController.php

@@ -116,7 +116,8 @@ class VoucherController extends Controller
      * @param Voucher $voucher
      * @param Voucher $voucher
      * @return LengthAwarePaginator
      * @return LengthAwarePaginator
      */
      */
-    public function users(Request $request, Voucher $voucher){
+    public function users(Request $request, Voucher $voucher)
+    {
         $request->validate([
         $request->validate([
             'include' => [
             'include' => [
                 'nullable',
                 'nullable',
@@ -125,7 +126,7 @@ class VoucherController extends Controller
             ]
             ]
         ]);
         ]);
 
 
-        if($request->input('include') == 'discorduser'){
+        if ($request->input('include') == 'discorduser') {
             return $voucher->users()->with('discordUser')->paginate($request->query('per_page') ?? 50);
             return $voucher->users()->with('discordUser')->paginate($request->query('per_page') ?? 50);
         }
         }
 
 

+ 0 - 2
routes/api.php

@@ -28,10 +28,8 @@ Route::middleware('api.token')->group(function () {
     Route::resource('vouchers', VoucherController::class)->except('create', 'edit');
     Route::resource('vouchers', VoucherController::class)->except('create', 'edit');
 
 
     Route::get('/notifications/{user}', [NotificationController::class, 'index']);
     Route::get('/notifications/{user}', [NotificationController::class, 'index']);
-    Route::get('/notifications/{user}/unread', [NotificationController::class, 'indexUnread']);
     Route::get('/notifications/{user}/{notification}', [NotificationController::class, 'view']);
     Route::get('/notifications/{user}/{notification}', [NotificationController::class, 'view']);
     Route::post('/notifications/{user}', [NotificationController::class, 'send']);
     Route::post('/notifications/{user}', [NotificationController::class, 'send']);
     Route::delete('/notifications/{user}', [NotificationController::class, 'delete']);
     Route::delete('/notifications/{user}', [NotificationController::class, 'delete']);
-    Route::delete('/notifications/{user}/read', [NotificationController::class, 'deleteRead']);
     Route::delete('/notifications/{user}/{notification}', [NotificationController::class, 'deleteOne']);
     Route::delete('/notifications/{user}/{notification}', [NotificationController::class, 'deleteOne']);
 });
 });