bleuren/laravel-setting

A package to manage application settings through a database in Laravel applications.

v1.0.0 2024-04-26 09:08 UTC

This package is auto-updated.

Last update: 2024-04-27 10:14:06 UTC


README

This package provides an easy way to manage application settings via a database in Laravel applications. With this package, you can read and set project-specific parameters and use them within your code, leveraging the power of Laravel's caching to optimize access and modification of these settings.

Features

  • Store settings in a database with a unique key for each setting.
  • Automatically cache settings to improve performance.
  • Easy retrieval and updating of settings via a simple API.
  • Commands included for clearing settings cache.

Installation

To install the package, run the following command in your Laravel project:

composer require bleuren/laravel-setting

Configuration

After installation, publish the migration file with the following command:

php artisan vendor:publish --tag=laravel-setting

Run the migrations to create the settings table:

php artisan migrate

Usage

Getting a Setting

You can retrieve settings using the Setting facade. Here's an example of how to get a setting value:

$value = Setting::get('some_key', 'default_value');

Setting a Value

To update or create a new setting:

Setting::set('some_key', 'new_value', 'Optional description');

Clearing Cache

If you need to clear the cache for the settings, you can use the provided command:

php artisan setting:clear

This command will clear all cached settings.

Contributing

Contributions are welcome, and thank you for your interest in contributing to the Laravel Setting package. Please feel free to submit any issues or pull requests.

License

This Laravel Setting package is open-sourced software licensed under the MIT license.