/** * Run the migrations. * * @return void */ public function up() { $setting = Option::setting('site.languages')->first(); $keys = explode(',', $setting->option_value); $keys[] = 'ru'; $setting->option_value = implode(',', $keys); $setting->save(); }
public function update() { $settings = Option::lists('option_value', 'option_key'); foreach (Input::all() as $key => $value) { if (starts_with($key, '_') === false) { $key = str_replace('-', '.', $key); $value = trim($value); if (!is_null(MainHelper::stringToBool($value))) { $value = MainHelper::stringToBool($value); } else { if (empty($value)) { $value = null; } } if ($value != $settings[$key]) { Option::where('option_key', $key)->update(['option_value' => $value]); } } } return Redirect::route('admin.site.settings.index')->with('messages', ['Settings Saved!']); }
<?php use BFACP\Option; $options = []; $format = function (&$options, $keys, $value) use(&$format) { $keys ? $format($options[array_shift($keys)], $keys, $value) : ($options = $value); }; try { foreach (Option::all() as $option) { if ($option->option_value === 1 || $option->option_value === '1' || $option->option_value === 'true') { $format($options, explode('.', $option->option_key), true); } elseif ($option->option_value === 0 || $option->option_value === '0' || $option->option_value === 'false') { $format($options, explode('.', $option->option_key), false); } else { if ($option->option_key == 'site.languages') { $values = []; foreach (explode(',', $option->option_value) as $value) { $values[$value] = MainHelper::languages($value); } $format($options, explode('.', $option->option_key), $values); } else { $format($options, explode('.', $option->option_key), $option->option_value); } } } } catch (\Illuminate\Database\QueryException $e) { $options = []; } return $options;
public function run() { $options = [['option_key' => 'metabans.key', 'option_title' => 'Metabans API Key', 'option_value' => null, 'option_description' => 'API key for Metabans interaction.'], ['option_key' => 'metabans.user', 'option_title' => 'Metabans Username', 'option_value' => null, 'option_description' => 'The username of the API key account holder.'], ['option_key' => 'metabans.account', 'option_title' => 'Metabans Account', 'option_value' => null, 'option_description' => 'The account name you want to pull the metabans feed from.'], ['option_key' => 'metabans.enabled', 'option_title' => 'Use Metabans', 'option_value' => false, 'option_description' => 'Use metabans throughout the site or disable it completely. Default: Disabled'], ['option_key' => 'site.title', 'option_title' => 'Site Title', 'option_value' => 'BFAdminCP', 'option_description' => 'The name of the site in the page title.'], ['option_key' => 'site.motd', 'option_title' => 'Message of the Day', 'option_value' => null, 'option_description' => 'Set the Message of the Day.'], ['option_key' => 'site.ssl', 'option_title' => 'Force SSL', 'option_value' => false, 'option_description' => 'Force the site to run under an SSL connection. Your site must be configured for SSL connections. Default: Disabled'], ['option_key' => 'site.auth', 'option_title' => 'Require Login', 'option_value' => false, 'option_description' => 'Only show the site for logged in users. Default: Disabled'], ['option_key' => 'site.registration', 'option_title' => 'Allow User Registration', 'option_value' => true, 'option_description' => 'Enable user registrations. Default: Enabled'], ['option_key' => 'site.chatlogs.guest', 'option_title' => 'Allow Guest Viewing of Chatlogs', 'option_value' => true, 'option_description' => 'Should users be allowed to view the chatlogs when not logged in.'], ['option_key' => 'site.languages', 'option_title' => 'Available Languages', 'option_value' => implode(',', ['en', 'de', 'nl']), 'option_description' => 'List of languages compatible with the BFACP.'], ['option_key' => 'uptimerobot.key', 'option_title' => 'Uptime Robot API Key', 'option_value' => null, 'option_description' => 'Uptime Robot Main API Key'], ['option_key' => 'uptimerobot.enabled', 'option_title' => 'Use Uptime Robot', 'option_value' => false, 'option_description' => 'Enable uptime robot. Default: Disabled']]; Option::insert($options); }