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

27 lines
460 B

<?php
namespace App\Models;
use Illuminate\Support\Facades\Cache;
class Config extends SoftDeletesModel
{
/**
* 通过键名获取值
*/
public static function getValueByKey($key)
{
$config = Cache::remember('config_array', 300, function () {
return self::pluck('value', 'key')->toArray();
});
if (isset($config[$key])) {
return $config[$key];
}
return null;
}
}