/** * Run the database seeds. * * @return void */ public function run() { $options = array(array('key' => 'contact.email', 'value' => '*****@*****.**'), array('key' => 'contact.phone', 'value' => '+123456789'), array('key' => 'site.title', 'value' => 'Beznazvu')); foreach ($options as $option) { Option::create($option); } }
public function run() { Option::truncate(); $options = array(array('key' => 'site.name', 'value' => 'My Site Name'), array('key' => 'site.slogan', 'value' => 'The Great Website!'), array('key' => 'site.description', 'value' => 'My Site.'), array('key' => 'site.keywords', 'value' => 'pingpong, gravitano'), array('key' => 'tracking', 'value' => '<!-- GA Here -->'), array('key' => 'facebook.link', 'value' => 'https://www.facebook.com/pingponglabs'), array('key' => 'twitter.link', 'value' => 'https://twitter.com/pingponglabs'), array('key' => 'post.permalink', 'value' => '{slug}'), array('key' => 'ckfinder.prefix', 'value' => 'packages/pingpong/admin'), array('key' => 'admin.theme', 'value' => 'default'), array('key' => 'pagination.perpage', 'value' => 10)); foreach ($options as $option) { Option::create($option); } }
public function run() { Option::truncate(); $options = array(array('key' => 'site.name', 'value' => 'Straysh\'s Blog'), array('key' => 'site.slogan', 'value' => 'Straysh的博客管理后台'), array('key' => 'site.description', 'value' => 'It\'s a website of Straysh\'s'), array('key' => 'site.keywords', 'value' => 'pingpong, gravitano, blog, straysh'), array('key' => 'tracking', 'value' => '<!-- GA Here -->'), array('key' => 'facebook.link', 'value' => 'https://www.facebook.com/straysh'), array('key' => 'twitter.link', 'value' => 'https://twitter.com/straysh'), array('key' => 'post.permalink', 'value' => '{slug}'), array('key' => 'ckfinder.prefix', 'value' => 'packages/pingpong/admin'), array('key' => 'admin.theme', 'value' => 'default'), array('key' => 'pagination.perpage', 'value' => 10)); foreach ($options as $option) { Option::create($option); } }
/** * @param $key * @param null $default * @return null */ function option($key, $default = null) { try { $option = Option::findByKey($key)->first(); return !empty($option) ? $option->value : $default; } catch (PDOException $e) { return $default; } }
/** * Update the settings. * * @return mixed */ public function updateSettings() { $settings = \Input::all(); foreach ($settings as $key => $value) { $option = str_replace('_', '.', $key); Option::findByKey($option)->update(['value' => $value]); } return \Redirect::back()->withFlashMessage('Settings has been successfully updated!'); }