<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\KonfigurasiModel;

class KonfigurasiController extends Controller
{
    public function website()
    {
        $data = KonfigurasiModel::allKonfigurasi();
        return view('dashboard.konfigurasi.web', compact('data'));
    }


    public function update(Request $request)
    {
        $validated = $request->except(['_token', '_method']);
        if ($request->hasFile('logo')) {
            $imageName = time() . '.' . $request->logo->extension();
            $request->logo->move(public_path('storage/logo'), $imageName);
            $validated['logo'] = $imageName;
        }

        KonfigurasiModel::updateKonfigurasi($validated);

        return redirect()->back()->with('success', 'Konfigurasi berhasil diupdate');
    }

    public function tentang()
    {
        $data = KonfigurasiModel::allKonfigurasi();
        return view('dashboard.konfigurasi.tentang', ['data' => $data]);
    }
}
