<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Routing\Controller as BaseController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;
use App\Models\User;
use App\Models\Settings;
use App\Models\UserDocuments;
use App\Models\WalletHistoryUsers;
use Illuminate\Support\Facades\Validator;

class SettingController extends BaseController
{
    public function index(){

        $settings = Settings::select('key', 'value')->get()->keyBy('key')->toArray();
        //print_r($settings); exit;
        return view('admin.settings.index', compact('settings'));
    }
    public function store(Request $request)
    {
        
        $requestData = $request->all();
        
        foreach($requestData as $key => $value){
            $setting = Settings::where('key', $key);
            $settaingData = [
                'key' => $key,
                'value' => $value,
            ];
            $setting->update($settaingData);
        }
        return redirect('admin/settings')->with('flash_message', 'Settings Updated');
    }
}
