some more cleanup for migrations

This commit is contained in:
Nabeel Shahzad 2017-06-20 22:48:16 -05:00
parent c27a11ab21
commit 807316fd0e
7 changed files with 71 additions and 104 deletions

View File

@ -1,6 +1,7 @@
APP_ENV=dev
APP_KEY=base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI=
APP_DEBUG=true
APP_LOCALE=en
APP_LOG_LEVEL=debug
APP_URL=http://localhost
APP_SETTINGS_STORE=json

View File

@ -2,40 +2,40 @@
namespace App\Http\Controllers\Admin;
use App\Models\Setting;
use App\Http\Requests;
use Redirect;
use Titan\Controllers\TitanAdminController;
use Illuminate\Http\Request;
class SettingsController extends BaseController
{
/**
* Display a listing of setting.
*
* @return Response
*/
public function index()
{
return $this->view('admins.settings.index')->with('items', Setting::all());
}
/**
* Display a listing of setting.
*
* @return Response
*/
public function index()
{
$settings = array_filter(Setting::all(), function ($key) {
if (strpos($key, '_descrip') !== false) { return true; }
return false;
});
/**
* Update the specified setting in storage.
*
* @param Setting $setting
* @param Request $request
return $this->view('admins.settings.index')
->with('settings', $settings);
}
/**
* Update the specified setting in storage.
*
* @param Setting $setting
* @param Request $request
*
* @return Response
*/
public function update(Setting $setting, Request $request)
{
$this->validate($request, Setting::$rules, Setting::$messages);
{
$this->validate($request, Setting::$rules, Setting::$messages);
$this->updateEntry($setting, $request->all());
return redirect("/admin/settings");
}
}
}

View File

@ -2,58 +2,19 @@
return [
/*
| Application Name
*/
'name' => 'phpvms',
/*
| Application Environment
*/
'env' => env('APP_ENV', 'dev'),
/*
| Application Debug Mode
*/
'debug' => env('APP_DEBUG', true),
/*
| Application URL
*/
'url' => env('APP_URL', 'http://localhost'),
'version' => '2.0',
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
'locale' => 'en',
'timezone' => env('APP_TIMEZONE', 'UTC'),
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
| Logging Configuration
*/
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),

View File

@ -2,14 +2,10 @@
return [
'currencies' => [
'dollar',
'euro',
'gbp',
'yen',
'jpy',
'rupee',
'rouble',
],
/**
* Pick one of:
* dollar, euro, gbp, yen, jpy, rupee, ruble
*/
'currency' => 'dollar',
];

View File

@ -7,40 +7,40 @@ use Illuminate\Support\Facades\Config;
class CreateSettingsTable extends Migration
{
public function __construct()
{
public function __construct()
{
$this->tablename = Config::get('settings.table');
$this->keyColumn = Config::get('settings.keyColumn');
$this->valueColumn = Config::get('settings.valueColumn');
}
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create($this->tablename, function(Blueprint $table)
{
$table->increments('id');
$table->string($this->keyColumn)->index();
$table->text($this->valueColumn);
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create($this->tablename, function (Blueprint $table) {
$table->increments('id');
$table->string($this->keyColumn)->index();
$table->text($this->valueColumn);
$table->timestamps();
});
});
Setting::set('timezone', 'UTC');
Setting::set('currency', 'dollar');
Setting::save();
}
#Setting::set('currency', 'dollar');
#Setting::set('currency_descrip', 'Currency to use');
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop($this->tablename);
}
#Setting::save();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop($this->tablename);
}
}

View File

@ -27,6 +27,7 @@ class CreateUsersTable extends Migration
$table->boolean('confirmed')->nullable();
$table->boolean('retired')->nullable();
$table->dateTime('last_pirep')->nullable();
$table->integer('timezone')->default(0);
$table->rememberToken();
$table->timestamps();
});

View File

@ -2,12 +2,20 @@
<thead>
<th>Name</th>
<th>Value</th>
<th>Description</th>
</thead>
<tbody>
@foreach($settings as $s)
<tr>
<td>{!! $s->key !!}</td>
<td>{!! $s->value !!}</td>
<td>
@if(Setting::get($s->key.'_descrip'))
{!! Setting::get($s->key.'_descrip') !!}
@else
&nbsp;
@endif
</td>
</tr>
@endforeach
</tbody>