<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use App\Models\WebsiteConfig as WebsiteConfigModel;
use Illuminate\Support\Facades\Session;

class WebsiteConfig
{
    public function handle(Request $request, Closure $next)
    {
        $websiteConfigs = WebsiteConfigModel::get();
        foreach ($websiteConfigs as $item) {
            $request->attributes->add([$item->key => json_decode($item->value)]);
        }
        return $next($request);
    }
}