<?php
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\FcmToken;
use Illuminate\Support\Facades\Auth;

class FcmTokenController extends Controller
{
    public function store(Request $request)
    {
        $request->validate([
            'token' => 'required|string',
        ]);
        $user = Auth::user();
        if (!$user) {
            return response()->json(['message' => 'Unauthorized'], 401);
        }
        // Simpan atau update token
        $fcmToken = FcmToken::updateOrCreate(
            [
                'user_id' => $user->id,
                'token' => $request->token,
            ],
            []
        );
        return response()->json(['success' => true]);
    }
} 