<?php

namespace App\Modules\Customization\CustomFields\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class EnsureCustomFieldsPlanEnabled
{
    public function handle(Request $request, Closure $next): Response
    {
        if ($request->user()?->can('custom_fields.plan') !== true) {
            abort(Response::HTTP_FORBIDDEN);
        }

        return $next($request);
    }
}
