HEX
Server: LiteSpeed
System: Linux s3604.bom1.stableserver.net 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: dmstechonline (1480)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/dmstechonline/whatsapp.dmstech.online/app/Http/Middleware/CheckEmailVerification.php
<?php

namespace App\Http\Middleware;

use Closure;
use App\Models\Setting;
use Illuminate\Support\Facades\Auth;

class CheckEmailVerification
{
    public function handle($request, Closure $next)
    {
        // Check if the user is logged in
        if (Auth::check()) {
            $user = Auth::user();
            $config = Setting::where('key', 'verify_email')->first();

            // Check if the user role is 'user'
            if (isset($config->value) && $config->value == '1' && $user->email_verified_at === NULL) {
                return to_route('verification.notice');
            }
        }

        // Subscription is active or user role is not 'user', proceed to the next page
        return $next($request);
    }
}