<?php

namespace App\Http\Controllers\Web;

use Inertia\Inertia;
use App\Http\Controllers\Controller;
use App\Models\Setting;

class SettingController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return Inertia::render('Settings', [
            'settings' => [
                'text' => settings('text'),
                'local_price' => settings('local_price'),
                'int_price' => settings('int_price'),
            ]
        ]);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store()
    {
        settings()->put(
            request()->only(['text', 'local_price', 'int_price'])
        );

        return redirect()->back();
    }
}
