Erhnam
Erhnam

Reputation: 921

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?

Upvotes: 3

Views: 698

Answers (2)

Erik
Erik

Reputation: 555

If I understand your question correctly view composers come in handy here.

Upvotes: 0

John Corry
John Corry

Reputation: 1577

You might want to try this...

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

Upvotes: 1

Related Questions