<?php

namespace app\Http\Middleware;

use App\Jobs\InsertDeviceResultJob;
use App\Jobs\KirimPesanOtomatisJob;
use App\Jobs\SimpanPesanOtomatisJob;
use App\Models\DeviceReportModel;
use App\Models\DeviceResultModel;
use App\Models\GroupDetailModel;
use App\Models\GroupPenerimaModel;
use App\Models\GroupWaSettingModel;
use App\Models\MessageModel;
use App\Models\PegawaiModel;
use App\Models\PenerimaBroadcastModel;
use App\Models\SettingSiagaModel;
use App\Models\TokenWaModel;
use App\Models\User;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class AuthAdminMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
     */
    public function handle(Request $request, Closure $next)
    {
        $login = session()->get("login");
        $id = session()->get('id');
        $email = session()->get('email');
        $name = session()->get('name');
        $uuid_level = session()->get('uuid_level');
        $photo = session()->get('photo_profile');
        $active = session()->get('active');
        $password = session()->get('password');
        $level = session()->get('level');
        if (!isset($login) || !isset($id) || !isset($email) || !isset($name) || !isset($uuid_level) || !isset($photo) || !isset($active) || !isset($password) || !isset($level)) {
            return redirect()->to("/");
        }

        
        
        return $next($request);
    }
}
