Introduce new Setting model. Set the site name.

This commit is contained in:
James Brooks
2014-11-17 14:45:24 +00:00
parent 8562062fcb
commit ad7e1b7439
6 changed files with 71 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSettingsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('settings', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->text('value')->nullable()->default(null);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('settings');
}
}

View File

@@ -11,7 +11,7 @@ class DatabaseSeeder extends Seeder {
{
Eloquent::unguard();
// $this->call('UserTableSeeder');
$this->call('SettingsTableSeeder');
}
}

View File

@@ -0,0 +1,27 @@
<?php
class SettingsTableSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
$defaultSettings = [
[
"name" => "site_name",
"value" => "Test"
]
];
Setting::truncate();
foreach($defaultSettings as $setting) {
Setting::create($setting);
}
}
}

7
app/models/Setting.php Normal file
View File

@@ -0,0 +1,7 @@
<?php
class Setting extends Eloquent {
public static function get($settingName) {
return self::where('name', $settingName)->first()->value;
}
}

View File

@@ -5,7 +5,7 @@
<div class='masthead-container'>
<div class='masthead'>
<div class='text-container'>
<span class='page-name font-largest'><a href='#'>SITE_NAME</a></span>
<span class='page-name font-largest'><a href='#'>{{ Setting::get('site_name') }}</a></span>
</div>
</div>
</div>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Cachet</title>
<title>{{ Setting::get('site_name') }} | Cachet</title>
<!-- Set the viewport width to device width for mobile -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="http://james-brooks.uk">