Skip to content

Commit

Permalink
Laravel 5.5 autodiscovery.
Browse files Browse the repository at this point in the history
Updated the package to be autodiscovered.
  • Loading branch information
SidharthRaveendran authored and anlutro committed Nov 8, 2017
1 parent 1756911 commit 48c9adb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ Despite the package name, this package works with Laravel 5.x!

- Class not found errors: https://github.com/anlutro/laravel-settings/issues/38

## Installation
## Installation - Laravel >= 5.5

1. `composer require anlutro/l4-settings`
2. Publish the config file by running `php artisan vendor:publish --provider="anlutro/l4-settings" --tag="config"`. The config file will give you control over which storage engine to use as well as some storage-specific settings.

## Installation - Laravel < 5.5

1. `composer require anlutro/l4-settings`
2. Add `anlutro\LaravelSettings\ServiceProvider` to the array of providers in `config/app.php`.
Expand Down
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
"anlutro\\LaravelSettings\\": "src/"
}
},
"extra": {
"laravel": {
"aliases": {
"Setting": "anlutro\\LaravelSettings\\Facade"
},
"providers": [
"anlutro\\LaravelSettings\\ServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
7 changes: 6 additions & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ public function register()
*/
public function boot()
{
if (version_compare(Application::VERSION, '5.0', '>=')) {
if (version_compare(Application::VERSION, '5.3', '>=')) {
$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');
Expand Down
47 changes: 35 additions & 12 deletions src/config/config.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
<?php
return array(
// which type of store to use.
// valid options: 'json', 'database'

return [
/*
|--------------------------------------------------------------------------
| Default Settings Store
|--------------------------------------------------------------------------
|
| This option controls the default settings store that gets used while
| using this settings library.
|
| Supported: "json", "database"
|
*/
'store' => 'json',

// if the json store is used, give the full path to the .json file
// that the store writes to.
/*
|--------------------------------------------------------------------------
| JSON Store
|--------------------------------------------------------------------------
|
| If the store is set to "json", settings are stored in the defined
| file path in JSON format. Use full path to file.
|
*/
'path' => storage_path().'/settings.json',

// if the database store is used, set the name of the table used..
'table' => 'settings',

// If the database store is used, you can set which connection to use. if
// set to null, the default connection will be used.
/*
|--------------------------------------------------------------------------
| Database Store
|--------------------------------------------------------------------------
|
| The settings are stored in the defined file path in JSON format.
| Use full path to JSON file.
|
*/
// If set to null, the default connection will be used.
'connection' => null,

// Name of the table used.
'table' => 'settings',
// If you want to use custom column names in database store you could
// set them in this configuration
'keyColumn' => 'key',
'valueColumn' => 'value'
);
];

0 comments on commit 48c9adb

Please sign in to comment.