You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
795 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Config;
use Illuminate\Support\Facades\Storage;
use Yo;
use Login;
class ConfigController extends Controller
{
public function get()
{
$label_arr = request()->post('label_arr');
$configs = $this->get_config_list($label_arr);
$list = [];
foreach ($configs as $config) {
$value = $config->value;
if (in_array($config->type, [3, 4, 5, 6])) {
$value = json_decode($value, true);
}
$list[$config->label] = $value;
}
return Yo::echo($list);
}
public function get_config_list($arr): array
{
$config_arr = [];
foreach ($arr as $item) {
$config = Config::where('label', $item)->first();
if ($config) $config_arr[] = $config;
}
return $config_arr;
}
}