0

Can anyone recommend the best practice for storing general site preferences. I want to store Site details in database like WordPress theme setting. Can any one can help??

My Table:

+------------------+--------------------+------------------+
|            id    | setting_key        | setting_value    |             
+------------------+--------------------+------------------+
|             1    | website_name       | Website Name     |
+----------------------------------------------------------+          
Alok Patel
  • 7,842
  • 5
  • 31
  • 47
sarun
  • 298
  • 5
  • 23
  • What do you mean by general site preferences ? which kind of data do you store there ? – Ismail H Jul 26 '16 at 07:45
  • 3
    Possible duplicate of [Best table design for application configuration or application option settings?](http://stackoverflow.com/questions/1387294/best-table-design-for-application-configuration-or-application-option-settings) – Last1Here Jul 26 '16 at 07:46
  • Like Wordpress meta values saving(Theme Setting) – sarun Jul 26 '16 at 07:47

1 Answers1

0

I know you want to store them in a mySQL db but have you considered putting them in the same place Laravel stores the configuration settings in the '/config' folder.

To do this create a file in the config folder called settings.php which will contain:

<?php

return [

    'website' => 'Website Name'

];

Then to access or modify the value:

// Get value
$website = Config::get('settings.website');

// Set value
Config::set('settings.website', 'New Website Name');
Rob
  • 6,758
  • 4
  • 46
  • 51