0

I would like to store my application settings in database. In order to get a variable in template, I'm currently using

{{ Config::get('file.variable) }} and settings are stored in config/file

I would like to create controller SettingsController with public static get and set methods and get variables in template in this way:

{{ Settings::get('var_name') }}

instead of

{{ SettingsController::get('var_name') }}

But I'm getting error: Class 'Settings' not found.

I've tried to set routes:

Route::controller('Settings', 'SettingsController'); and
Route::resource('Settings', 'SettingsController');

But none of the methods works. Any ideas how to solve this problem?

mpet
  • 983
  • 4
  • 15
  • 33
  • well, i don't think you need to define controller, just create a model with setting, map it according to your requirement and call it where ever you want to call. – Safoor Safdar Feb 25 '15 at 09:17
  • 1
    and also take a look to package: https://github.com/anlutro/laravel-settings. – Safoor Safdar Feb 25 '15 at 09:18
  • It would be called Setting then, I thought if it can be done using controller instead of model – mpet Feb 25 '15 at 09:32

1 Answers1

0

This should be done using facades, which is already answered here:

How to create custom Facade in Laravel 4

Community
  • 1
  • 1
mpet
  • 983
  • 4
  • 15
  • 33