i want to create setting model LIKE tcg/voyager to can use like this *** setting(‘site.title’) *** . how to generate ?
iwant to save to db.
like tcg/voyager .
thanks.
i want to create setting model LIKE tcg/voyager to can use like this *** setting(‘site.title’) *** . how to generate ?
iwant to save to db.
like tcg/voyager .
thanks.
2
Answers
You may create custom configuration files in the
config/
folder of your Laravel project. These files should return an array where the key is the option name and the value is the value of the option.As per the documentation:
I did the same not so long ago, it is fairly easy.
Inside composer.json "autoload" add "files": ["app/helpers.php"]
Create file in that directory
Create a table in DB called i.e. settings with columns key and value
Write a function i.e. setting($your_key, $defaultValue = ”) which will query table settings where ‘key’ = $your_key and return value if row exists, if not return $defaultValue
In blade you can call it same as Voyager setting
{{setting('key', '')}}
You will need to run composer again so that your autoload file will be recognized