<?php

namespace App\Http\Controllers\notifications;

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

class NotificationController extends Controller
{
    public function proceed(Request $request, $notificationId)
    {
        $user = Auth::user();
        $notifications = $user->notifications;

        foreach ($notifications as $notification) {
            if ($notification->id == $notificationId) {
                $notification->delete();
                return redirect()->to($notification->data["referral"]);
            }
        }

        return back();
    }
}
