<?php
namespace App\Services;

use Illuminate\Support\Facades\DB;

class ConfigService
{

    //获取配置信息
    public function GetConfigInfo($arr,$is_admin=false){
      $q=DB::table('configs')->select(['label','value']);
      if($is_admin){

      }else{
        $q=$q->whereIn('label',$arr);
      }
        $q=$q->get();
        if(count($q)>0) {
            $result = [];
            foreach ($q as $k => $v) {
                $result[$v->label] = $v->value;
            }
            return \Yz::Return(true, '查询成功', $result);
        }else{
            return \Yz::Return(false, '查询失败');
        }
    }
    public function SaveConfig($data){
      foreach ($data as $key=>$item){
        $u=DB::table('configs')->where('label', '=', $key)->update(['value'=>$item]);
      }
        if($u){
          return \Yz::Return(true, '操作成功');
        }else{
          return \Yz::Return(false, '操作失败');
        }





    }
}
