mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 21:59:24 +08:00
Extract config into database
This commit is contained in:
parent
a0ade68d65
commit
c3aecbceaa
|
@ -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']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 »</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');
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user