dstpabuaran.com/app/Http/Controllers/Api/PushSubscriptionController.php
Yoga Pangestu 95be00c9d1 feat: add push notification functionality and service worker
- Implemented push notifications with a service worker (sw.ts) to handle caching and notifications.
- Added API routes for push subscription and notification management in routes/api.php.
- Created NotificationTest to validate notification service functionality and ensure correct notifications are sent based on user roles and actions.
- Updated Permissions component to manage notification permissions and subscriptions.
- Enhanced CategoryIndex component to highlight categories based on notifications.
- Excluded service worker from TypeScript compilation in tsconfig.json.
- Updated Vite configuration to include service worker in the build process.
2026-08-01 11:36:20 +07:00

36 lines
949 B
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\Api\DestroyPushSubscriptionRequest;
use App\Http\Requests\Api\StorePushSubscriptionRequest;
use App\Services\PushSubscriptionService;
use Illuminate\Http\JsonResponse;
class PushSubscriptionController extends Controller
{
public function __construct(
private readonly PushSubscriptionService $service,
) {}
public function store(StorePushSubscriptionRequest $request): JsonResponse
{
return $this->service->store(
$request->user(),
$request->endpoint,
$request->public_key,
$request->auth_token,
$request->content_encoding,
);
}
public function destroy(DestroyPushSubscriptionRequest $request): JsonResponse
{
return $this->service->destroy(
$request->user(),
$request->endpoint,
);
}
}