<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;

class UnsubscribeController extends Controller
{
    public function handle(Request $request)
    {
        $token = $request->token;

        $user = User::where('unsubscribe_token', $token)->first();

        if ($user) {
            $user->subscribed = false;
            $user->save();
        }

        return response('Unsubscribed', 200);
    }
}
