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.

14 lines
486 B

2 years ago
  1. <?php
  2. use Illuminate\Support\Arr;
  3. function setting($key) {
  4. // if the key that user provided not exists then null return
  5. $settings = $key != "" ? Arr::get(app()->settings, $key, null) : app()->settings;
  6. // if settings null means that key not found
  7. throw_if($settings === null, 'Exception', "Undefined enum '{$key}'");
  8. // if settings value is array its mean that user want to use it as collection
  9. return is_array($settings) ? collect($settings) : $settings;
  10. }