OAuth.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\common\models;
  10. class OAuth extends Model {
  11. protected $name = "oauth";
  12. /**
  13. * 获取配置
  14. * @param string $name
  15. * @param string $value
  16. * @return array|mixed|string
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public static function getSetting($name,$value=""){
  22. $row = self::where(["name"=>$name])->find();
  23. if(empty($row["config"])) return null;
  24. $array = json_decode($row["config"],true);
  25. if(empty($array)){
  26. return $array;
  27. }
  28. if(isset($array[$value])){
  29. return trim($array[$value]);
  30. }
  31. return null;
  32. }
  33. public function getConfigAttr($value){
  34. if(empty($value)) return "";
  35. return json_decode($value,true);
  36. }
  37. }