Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migration publishing, update config publishing and environmental variables #82

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Laravel 4 - Persistent Settings
*
*
* @author Andreas Lutro <anlutro@gmail.com>
* @license http://opensource.org/licenses/MIT
* @package l4-settings
Expand Down Expand Up @@ -36,7 +36,7 @@ public function register()
$app->make('anlutro\LaravelSettings\SettingStore')->save();
});
}

/**
* Construct the actual manager.
*/
Expand All @@ -58,23 +58,20 @@ public function register()
*/
public function boot()
{
if (version_compare(Application::VERSION, '5.3', '>=')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codetheorist add this back.

$this->loadMigrationsFrom(__DIR__.'/migrations');
$this->publishes([
__DIR__.'/config/config.php' => config_path('settings.php')
], 'config');
} else if (version_compare(Application::VERSION, '5.0', '>=')) {
$this->publishes([
__DIR__.'/config/config.php' => config_path('settings.php')
], 'config');
$this->publishes([
__DIR__.'/config/config.php' => config_path('settings.php'),
], 'config');

$this->mergeConfigFrom(__DIR__.'/config/config.php', 'settings');

if (! class_exists('CreateSettingsTable')) {
$timestamp = date('Y_m_d_His', time());

$this->publishes([
__DIR__.'/migrations' => database_path('migrations')
__DIR__.'/migrations/create_settings_table.php.stub' => database_path("/migrations/{$timestamp}_create_settings_table.php"),
], 'migrations');
} else {
$this->app['config']->package(
'anlutro/l4-settings', __DIR__ . '/config', 'anlutro/l4-settings'
);
}

}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
| Supported: "json", "database"
|
*/
'store' => 'json',
'store' => env('SETTINGS_STORE', 'json'),

/*
|--------------------------------------------------------------------------
Expand All @@ -23,7 +23,7 @@
| file path in JSON format. Use full path to file.
|
*/
'path' => storage_path().'/settings.json',
'path' => storage_path().env('SETTINGS_PATH', '/settings.json'),

/*
|--------------------------------------------------------------------------
Expand All @@ -35,11 +35,11 @@
|
*/
// If set to null, the default connection will be used.
'connection' => null,
'connection' => env('SETTINGS_CONNECTION', null),
// Name of the table used.
'table' => 'settings',
// If you want to use custom column names in database store you could
'table' => env('SETTINGS_TABLE', 'settings'),
// If you want to use custom column names in database store you could
// set them in this configuration
'keyColumn' => 'key',
'valueColumn' => 'value'
'keyColumn' => env('SETTINGS_KEY_COLUMN', 'key'),
'valueColumn' => env('SETTINGS_VALUE_COLUMN', 'value')
];
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ class CreateSettingsTable extends Migration
{
public function __construct()
{
if (version_compare(Application::VERSION, '5.0', '>=')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codetheorist add this back.

$this->tablename = Config::get('settings.table');
$this->keyColumn = Config::get('settings.keyColumn');
$this->valueColumn = Config::get('settings.valueColumn');
} else {
$this->tablename = Config::get('anlutro/l4-settings::table');
$this->keyColumn = Config::get('anlutro/l4-settings::keyColumn');
$this->valueColumn = Config::get('anlutro/l4-settings::valueColumn');
}
$this->tablename = Config::get('settings.table');
$this->keyColumn = Config::get('settings.keyColumn');
$this->valueColumn = Config::get('settings.valueColumn');
}

/**
Expand Down