From 0e5d18c0a15d6df8ad4c057d33b5654508c8f0e4 Mon Sep 17 00:00:00 2001 From: printempw Date: Wed, 17 Aug 2016 12:16:03 +0800 Subject: [PATCH] import option automatically if exists --- app/Services/Option.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Services/Option.php b/app/Services/Option.php index c694347e..bb5c7918 100644 --- a/app/Services/Option.php +++ b/app/Services/Option.php @@ -15,6 +15,12 @@ class Option if (!is_null($default_value)) { return $default_value; } else { + $options = require BASE_DIR."/setup/options.php"; + + if (array_key_exists($key, $options)) { + self::add($key, $options[$key]); + return $options[$key]; + } throw new Exception('Unexistent option.', 1); } } @@ -39,7 +45,7 @@ class Option return true; $option = new OptionModel; - $option->option_name = $key; + $option->option_name = $key; $option->option_value = $value; $option->save(); }