Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

system-settings-db

Very simple package for storing settings for your Laravel project in the database.

Requirements

  • PHP 8.3+
  • Laravel 12 or 13

Installation

Install the package with composer:

composer require core45/system-settings-db

Publish the package files:

php artisan vendor:publish --tag=system-settings-db

Or publish only one part:

php artisan vendor:publish --tag=system-settings-db-config
php artisan vendor:publish --tag=system-settings-db-migrations

Migrate the database:

php artisan migrate

Usage

After migrating the new table system_settings will be created in the database. The package doesn't provide a UI for managing the settings. You have to add/modify/delete the records on your own. The important columns are:

  • key: the key of the setting
  • value: the value of the setting

The other columns are for your convenience. You can also add your own columns to the table if you like.

Setting a value

In the database you can set a value for a key. The key is a string and the value can be a string, integer or boolean.

To access the value of a key you can use the config() helper function.

config('system-settings.some-key');

So for example in your blade template you can use your contact email you previously stored in the settings table:

My email is: <a href="mailto:{{ config('system-settings.email') }}">{{ config('system-settings.email') }}</a>

Cache

The package uses the Laravel cache so if you'd like to see the changes immediately clean the Laravel cache. Default TTL of the cache is 60 seconds. You can change this setting in the config file.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages