Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

msaad's avatar
Level 1

Laravel Config Values From Database Setting Table

Hello Friends, I want to ask about laravel config values from the database table name "site_settings";

I want to get all configuration values from the "site_settings" table. Like: DB_DATABASE DB_USERNAME DB_PASSWORD MAIL_USERNAME MAIL_PASSWORD

Google client_id Google client_secret Google redirect etc.

Which way is best to do this? Plz, Help me. Thanks

0 likes
7 replies
NemoPS's avatar

does the table have an associated "configuration" class? I didn't test it but if so I believe you can edit config/database.php and add your values like Configuration::where('key', 'nameofit')->first()->pluck('value')

if indeed your columns are named key and value

msaad's avatar
Level 1

@NemoPS Thanks

E.g I have stored DB_USERNAME & DB_PASSWORD in the site_settings table. Now I want to get DB_USERNAME & DB_PASSWORD in the .env file OR in the config file in laravel. How can I do this?

msaad's avatar
Level 1

@Levente_N Thanks Is there any way to store all values of site_setting in the config in array & get these values according to requirement?

Levente_N's avatar

@msaad Example: You have your form right? that form has an input named site_settings

When you submit the form you can do this to set that config value config('settings.site_name', $request->input('site_name'));

then to access it you just call config('settings.site_name');

Levente_N's avatar

same can be applied for your google secret and others

msaad's avatar
Level 1

Or is any way to store values in cache and use these values.

Please or to participate in this conversation.