diff --git a/README.md b/README.md index 42ffff9..6201116 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ You can either use the helper method like `setting('foo')` or the facade `Settin ```php Setting::get('foo', 'default'); Setting::get('nested.element'); +Setting::getKeys(['foo', 'bar']); Setting::set('foo', 'bar'); Setting::forget('foo'); $settings = Setting::all(); diff --git a/src/Contracts/Driver.php b/src/Contracts/Driver.php index a26956a..f9acc96 100644 --- a/src/Contracts/Driver.php +++ b/src/Contracts/Driver.php @@ -64,6 +64,28 @@ public function get($key, $default = null) return Arr::get($this->data, $key, $default); } + /** + * @param array $keys + * @param $default + * @return array|false + */ + public function getKeys(array $keys, $default = null) + { + $keysWithValues = []; + + foreach ($keys as $key) { + if (!$this->checkExtraColumns()) { + return false; + } + + $this->load(); + + $keysWithValues[$key] = Arr::get($this->data, $key, $default); + } + + return $keysWithValues; + } + /** * Get the fallback value if default is null. *