Extract config into database

This commit is contained in:
Toby Zerner 2015-05-02 08:07:51 +09:30
parent a0ade68d65
commit c3aecbceaa
4 changed files with 18 additions and 8 deletions

View File

@ -40,8 +40,11 @@ class SeedCommand extends Command {
*/
public function fire()
{
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\GroupsTableSeeder']);
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\PermissionsTableSeeder']);
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\UsersTableSeeder']);
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\DiscussionsTableSeeder']);
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\ConfigTableSeeder']);
}
/**

View File

@ -1,6 +1,7 @@
<?php namespace Flarum\Core\Seeders;
use Illuminate\Database\Seeder;
use DB;
class ConfigTableSeeder extends Seeder {
@ -11,7 +12,17 @@ class ConfigTableSeeder extends Seeder {
*/
public function run()
{
//
$config = [
'api_url' => 'http://flarum.dev/api',
'base_url' => 'http://flarum.dev',
'forum_title' => 'Flarum Demo Forum',
'welcome_message' => 'Flarum is now at a point where you can have basic conversations, so here is a little demo for you to break.',
'welcome_title' => 'Welcome to Flarum Demo Forum'
];
DB::table('config')->insert(array_map(function($key, $value) {
return compact('key', 'value');
}, array_keys($config), $config));
}
}

View File

@ -6,17 +6,13 @@ use Auth;
use Cookie;
use Config;
use View;
use DB;
class IndexAction extends BaseAction
{
public function handle(Request $request, $params = [])
{
$config = [
'baseURL' => 'http://flarum.dev',
'apiURL' => 'http://flarum.dev/api',
'forumTitle' => Config::get('flarum::forum_title', 'Flarum Demo Forum'),
'welcomeDescription' => 'Flarum is now at a point where you can have basic conversations, so here is a little demo for you to break. <a href="http://demo.flarum.org/#/1/welcome-to-the-first-public-demo-of-flarum">Learn more &raquo;</a>'
];
$config = DB::table('config')->whereIn('key', ['base_url', 'api_url', 'forum_title', 'welcome_title', 'welcome_message'])->lists('value', 'key');
$data = [];
$session = [];
$alert = Session::get('alert');

View File

@ -4,7 +4,7 @@
<header class="global-header" id="header">
<div id="back-button"></div>
<div class="container">
<h1 class="header-title"><a href="#" onclick="app.history.home()">Flarum Demo Forum</a></h1>
<h1 class="header-title"><a href="#" onclick="app.history.home()">{{ $config['forum_title'] }}</a></h1>
<div id="header-primary" class="header-primary"></div>
<div id="header-secondary" class="header-secondary"></div>
</div>