| @@ 55-69 (lines=15) @@ | ||
| 52 | * |
|
| 53 | * @return \Illuminate\Http\JsonResponse |
|
| 54 | */ |
|
| 55 | public function delete(Request $request): JsonResponse |
|
| 56 | { |
|
| 57 | $user = Auth::user(); |
|
| 58 | $notification = $user->notifications() |
|
| 59 | ->where('id', $request->input('id')) |
|
| 60 | ->first(); |
|
| 61 | ||
| 62 | if ($notification) { |
|
| 63 | $notification->delete(); |
|
| 64 | } |
|
| 65 | ||
| 66 | return response()->json([ |
|
| 67 | 'error' => false |
|
| 68 | ]); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Mark a notification as read. |
|
| @@ 78-92 (lines=15) @@ | ||
| 75 | * |
|
| 76 | * @return \Illuminate\Http\JsonResponse |
|
| 77 | */ |
|
| 78 | public function markAsRead(Request $request): JsonResponse |
|
| 79 | { |
|
| 80 | $user = Auth::user(); |
|
| 81 | $notification = $user->notifications() |
|
| 82 | ->where('id', $request->input('id')) |
|
| 83 | ->first(); |
|
| 84 | ||
| 85 | if ($notification) { |
|
| 86 | $notification->markAsRead(); |
|
| 87 | } |
|
| 88 | ||
| 89 | return response()->json([ |
|
| 90 | 'error' => false |
|
| 91 | ]); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * Mark all notifications as read. |
|