fix comparing string with bool value

This commit is contained in:
printempw 2017-01-02 10:28:10 +08:00
parent 36014020e5
commit cc6afebfec
2 changed files with 6 additions and 3 deletions

View File

@ -250,7 +250,8 @@ class OptionForm
continue; continue;
} }
if (($data = Arr::get($_POST, $item->id)) != option($item->id)) { // compare with raw option value
if (($data = Arr::get($_POST, $item->id)) != option($item->id, null, true)) {
Option::set($item->id, $data); Option::set($item->id, $data);
} }
} }

View File

@ -32,10 +32,10 @@ class OptionRepository extends Repository
* *
* @param string $key * @param string $key
* @param mixed $default * @param mixed $default
* @param bool $bool convert '0', '1' to bool value * @param raw $raw return raw value without convertion
* @return mixed * @return mixed
*/ */
public function get($key, $default = null) public function get($key, $default = null, $raw = false)
{ {
if (!$this->has($key) && Arr::has(config('options'), $key)) { if (!$this->has($key) && Arr::has(config('options'), $key)) {
$this->set($key, config("options.$key")); $this->set($key, config("options.$key"));
@ -43,6 +43,8 @@ class OptionRepository extends Repository
$value = Arr::get($this->items, $key, $default); $value = Arr::get($this->items, $key, $default);
if ($raw) return $value;
switch (strtolower($value)) { switch (strtolower($value)) {
case 'true': case 'true':
case '(true)': case '(true)':