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_ENV=dev
APP_KEY=base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI= APP_KEY=base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI=
APP_DEBUG=true APP_DEBUG=true
APP_LOCALE=en
APP_LOG_LEVEL=debug APP_LOG_LEVEL=debug
APP_URL=http://localhost APP_URL=http://localhost
APP_SETTINGS_STORE=json APP_SETTINGS_STORE=json

View File

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

View File

@@ -2,58 +2,19 @@
return [ return [
/*
| Application Name
*/
'name' => 'phpvms', 'name' => 'phpvms',
/*
| Application Environment
*/
'env' => env('APP_ENV', 'dev'), 'env' => env('APP_ENV', 'dev'),
/*
| Application Debug Mode
*/
'debug' => env('APP_DEBUG', true), 'debug' => env('APP_DEBUG', true),
/*
| Application URL
*/
'url' => env('APP_URL', 'http://localhost'), 'url' => env('APP_URL', 'http://localhost'),
'version' => '2.0',
/* 'timezone' => env('APP_TIMEZONE', 'UTC'),
|-------------------------------------------------------------------------- 'locale' => env('APP_LOCALE', 'en'),
| 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',
'fallback_locale' => 'en', 'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
*/
'key' => env('APP_KEY'), 'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC', 'cipher' => 'AES-256-CBC',
/*
| Logging Configuration
*/
'log' => env('APP_LOG', 'single'), 'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'), 'log_level' => env('APP_LOG_LEVEL', 'debug'),

View File

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

View File

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

View File

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

View File

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