feat: add persistent mobile notifications
CI / 🧪 Tests Laravel (push) Successful in 2m7s
CI / 🐳 Build & Push Image (push) Successful in 42s

This commit is contained in:
2026-08-11 16:46:05 +02:00
parent bd1b4bba20
commit df4f523089
24 changed files with 822 additions and 75 deletions
@@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\UpdateNotificationPreferencesRequest;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class NotificationPreferenceController extends Controller
{
public function show(Request $request): JsonResponse
{
return response()->json([
'data' => $this->preferences($request),
]);
}
public function update(UpdateNotificationPreferencesRequest $request): JsonResponse
{
$user = $request->user();
$validated = $request->validated();
$user->forceFill([
'social_notifications_enabled' => $validated['socialNotificationsEnabled']
?? $user->social_notifications_enabled,
'engagement_reminders_enabled' => $validated['engagementRemindersEnabled']
?? $user->engagement_reminders_enabled,
])->save();
return response()->json([
'data' => $this->preferences($request),
'message' => __('api.notifications.preferences_updated'),
]);
}
/** @return array{socialNotificationsEnabled: bool, engagementRemindersEnabled: bool} */
private function preferences(Request $request): array
{
return [
'socialNotificationsEnabled' => (bool) $request->user()->social_notifications_enabled,
'engagementRemindersEnabled' => (bool) $request->user()->engagement_reminders_enabled,
];
}
}