From 688bf668e8721ce93713079b254b236311e6fff3 Mon Sep 17 00:00:00 2001 From: printempw Date: Mon, 17 Oct 2016 10:07:38 +0800 Subject: [PATCH] return bool value when option value is 0 or 1 --- app/Services/OptionRepository.php | 16 +++++++++++++++- resources/views/admin/options.tpl | 17 +++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/Services/OptionRepository.php b/app/Services/OptionRepository.php index 2a48a339..86b5e27b 100644 --- a/app/Services/OptionRepository.php +++ b/app/Services/OptionRepository.php @@ -57,7 +57,21 @@ class OptionRepository implements ArrayAccess, ConfigContract $this->set($key, config("options.$key")); } - return Arr::get($this->items, $key, $default); + $value = Arr::get($this->items, $key, $default); + + switch (strtolower($value)) { + case 'true': + case '1': + return true; + case 'false': + case '0': + return false; + case 'null': + case '(null)': + return; + } + + return $value; } /** diff --git a/resources/views/admin/options.tpl b/resources/views/admin/options.tpl index d52d64bc..1607848c 100644 --- a/resources/views/admin/options.tpl +++ b/resources/views/admin/options.tpl @@ -83,7 +83,7 @@ 开放注册 @@ -97,7 +97,7 @@ 最大允许上传大小 - +
@@ -111,7 +111,7 @@ 角色名 @@ -132,7 +132,7 @@ @@ -194,7 +194,8 @@ // pre-set some options because they will not be posted if not checked $presets = [ 'avatar_query_string', - 'return_200_when_notfound' + 'return_200_when_notfound', + 'auto_detect_asset_url' ]; foreach ($presets as $key) { @@ -217,7 +218,7 @@ 头像缓存 @@ -228,7 +229,7 @@ @@ -237,7 +238,7 @@ HTTP 响应码