Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Laravel 5, global variables or constants from database

I'm new to Laravel and wonder what the best approach is to use global variables or constants based on values within the database. Let's assume users can specify the site name, theme, admin email, default_image, language. These values are stored in the database and should be used across all controllers and views:

$config->admin_name = 'Administrator';

It could then be easily be used all controllers, views, etc by : $this->config->item('admin_name');

What is the best approach in Laravel?

like image 256
Erhnam Avatar asked Nov 27 '25 22:11

Erhnam


1 Answers

You might want to try this...

https://github.com/Grimthorr/laravel-user-settings

like image 106
John Corry Avatar answered Nov 29 '25 11:11

John Corry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!