/** * Execute the console command. * * @return mixed */ public function handle() { try { if ($key = $this->argument('key')) { $message = ""; $value = $this->argument('value'); $encrypt = $this->option('encrypt'); if (Str::isNullOrEmptyString($value)) { if ($encrypt) { $value = $this->secret('Enter secret value:'); $message = "Setting [{$key}] set to encrypted value."; } else { $value = $this->ask('Enter value:'); $message = "Setting [{$key}] set to [{$value}]."; } } Setting::set($key, $value, $encrypt); Setting::save(); $this->info($message); } else { $this->error("Missing 'key' argument."); } } catch (\Exception $ex) { $this->error("Exception: " . $ex->getMessage()); $this->error("Stack trace: " . $ex->getTraceAsString()); } }
/** * Execute the console command. * * @return mixed */ public function handle() { try { if ($key = $this->argument('key')) { $value = Setting::get($key); if (Str::isNullOrEmptyString($value)) { $this->comment("No setting found or empty setting."); } else { if (is_array($value)) { $value = Arr::dot($value); foreach ($value as $key2 => $value2) { $this->line("{$key}.{$key2}={$value2}"); } } else { $this->line($key . "=" . $value); } } } else { $this->error("Missing 'key' argument."); } } catch (\Exception $ex) { $this->error("Exception: " . $ex->getMessage()); $this->error("Stack trace: " . $ex->getTraceAsString()); } }
/** * Evaluate the input variable and if the string can be converted to either * a boolean, float or integer converts it and return that value. * Otherwise simply return the inout variable unchanged. * * @param $value * @return bool|float|int|misc */ public static function correctType($value) { try { if (Str::isBoolean($value)) { $value = Str::toBoolean($value); } elseif (is_float($value)) { $value = floatval($value); } elseif (is_int($value)) { $value = intval($value); } } catch (Exception $ex) { } return $value; }
/** * @return \Illuminate\View\View */ public function show($id) { $user = $this->user->find($id); Audit::log(Auth::user()->id, trans('admin/users/general.audit-log.category'), trans('admin/users/general.audit-log.msg-show', ['username' => $user->username])); $page_title = trans('admin/users/general.page.show.title'); // "Admin | User | Show"; $page_description = trans('admin/users/general.page.show.description', ['full_name' => $user->full_name]); // "Displaying user"; $perms = $this->perm->pushCriteria(new PermissionsByNamesAscending())->all(); $time_format = $user->settings()->get('time_format', null); $locales = Setting::get('app.supportedLocales'); $localeIdent = $user->settings()->get('locale', null); if (!Str::isNullOrEmptyString($localeIdent)) { $locale = $locales[$localeIdent]; } else { $locale = ""; } return view('admin.users.show', compact('user', 'perms', 'theme', 'time_format', 'locale', 'page_title', 'page_description')); }
/** * Execute the console command. * * @return mixed */ public function handle() { $envName = $this->argument('env'); if (Str::isNullOrEmptyString($envName)) { $envName = env('APP_ENV', 'production'); } try { $cnt = Setting::load($envName); Setting::save(); if (0 == $cnt) { $this->warn(trans('admin/settings/general.status.no-settings-loaded', ['env' => $envName])); } else { $this->info(trans('admin/settings/general.status.settings-loaded', ['number' => $cnt, 'env' => $envName])); } } catch (FileNotFoundException $fnfx) { $this->error(trans('admin/settings/general.status.settings-file-not-found', ['env' => $envName])); } catch (\Exception $ex) { $this->error("Exception: " . $ex->getMessage()); $this->error("Stack trace: " . $ex->getTraceAsString()); } }
/** * @param $val * @return bool */ public function isEncrypted($key, $val = null) { if (Str::isNullOrEmptyString($val)) { $val = $this->underlyingGet($key); } if (is_string($val) && Str::startsWith($val, self::$ENCRYPTED_PREFIX)) { return true; } else { return false; } }