routes response refactoring

This commit is contained in:
Čarodej
2022-05-16 14:14:48 +02:00
parent f66982b3ec
commit e87e2ec4e3
85 changed files with 534 additions and 316 deletions

View File

@@ -18,7 +18,10 @@ class FlushUserNotificationsController extends Controller
}
// Delete all notifications
auth()->user()->notifications()->delete();
auth()
->user()
->notifications()
->delete();
return response()->json($successMessage);
}

View File

@@ -1,15 +1,18 @@
<?php
namespace Domain\Notifications\Controllers;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use Domain\Notifications\Resources\NotificationCollection;
class GetUserNotificationsController extends Controller
{
public function __invoke(): NotificationCollection
public function __invoke(): JsonResponse
{
return new NotificationCollection(
$notifications = new NotificationCollection(
auth()->user()->notifications
);
return response()->json($notifications);
}
}

View File

@@ -18,9 +18,12 @@ class MarkUserNotificationsAsReadController extends Controller
}
// Mark all notifications as read
auth()->user()->unreadNotifications()->update([
'read_at' => now(),
]);
auth()
->user()
->unreadNotifications()
->update([
'read_at' => now(),
]);
return response()->json($successMessage);
}