<?php

namespace App\Http\Controllers\Api;

use App\Models\Config;
use App\User;
use Exception;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;


use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

class ConfigController extends BaseController
{
    // 配置列表
    public function getConfigs(Request $request) {
        $data = Config::query()->get();
        return $this->response($data);
    }


    // 修改配置
    public function updateConfigs(Request $request) {
        $rtn = [];
        $configurationData = $request->input('configs');
        foreach ($configurationData as $item) {
            $configuration = Config::query()->updateOrCreate([
                'name' => $item['name'],
            ], [
                // 'alias' => $item['alias'],
                // 'type' => $item['type'],
                'value' => $item['value'],
            ]);
            $rtn[] = $configuration;
        }
        return $this->response($rtn);
    }
}

