anlutro / laravel-settings

Persistent settings in Laravel
MIT License
940 stars 112 forks source link

Settings are not saving into database #102

Closed manojrhr closed 5 years ago

manojrhr commented 6 years ago

I have installed this repo to my laravel 5.6.12 and write this code

        setting()->set('foo', 'my value');
        setting()->save();

But my I didn't get anything in my settings table. Is there any thing I am missing?

Venipa commented 6 years ago

same for me

image

bweston92 commented 6 years ago

@Venrir can you share how you've set it up, and the code that sets and saves?

codevisiondevelopment commented 6 years ago

config/settings.php Change: 'store' => 'json' To 'store' => 'database'

leecraigjeffries commented 5 years ago

I'm having this same issue, the ::set() method does nothing, just returns null

::get() works perfectly fine, retrieving from the database as expected

Hiros101 commented 5 years ago

Make sure to run php artisan config:cache after changing config file.

sribna commented 3 years ago

Still not working for Lara 8

config/settings.php exists, 'store' => 'database' settings table also exists

Run php artisan config:cache several times

ddd(setting()->set('test', 'value')) returns NULL

ddd(setting(['test' => 'value'])) returns a different result ( why?)

anlutro\LaravelSettings\DatabaseSettingStore {#203 ▼
  #connection: Illuminate\Database\MySqlConnection {#200 ▶}
  #table: "settings"
  #keyColumn: "key"
  #valueColumn: "value"
  #queryConstraint: null
  #extraColumns: []
  #data: array:1 [▶]
  #updatedData: array:1 [▶]
  #persistedData: []
  #unsaved: true
  #loaded: true
  #defaults: array:1 [▶]
  #cache: null
  #cacheTtl: 15
  #cacheForgetOnWrite: true
}
bweston92 commented 3 years ago

@sribna setting() called with an array will set the configuration and then return the result. When you call set on the store it will not. set is correct to be void.

setting(): https://github.com/anlutro/laravel-settings/blob/6029f6aeb84fe74cdfb0c0152e69576033fb665f/src/helpers.php#L8

SettingStore::set(): https://github.com/anlutro/laravel-settings/blob/6029f6aeb84fe74cdfb0c0152e69576033fb665f/src/SettingStore.php#L148