forwardcode/laravel-options

Fetch/Store Key-Value Pair in Laravel

dev-master 2022-07-08 17:24 UTC

This package is auto-updated.

Last update: 2024-10-08 22:09:12 UTC


README

Global key-value store in the database

Installation

To get started with laravel-options, use Composer to add the package to your project's dependencies:

composer require forwardcode/laravel-options

Publish, migrate

By running php artisan vendor:publish --provider="Forwardcode\LaravelOptionsServiceProvider" in your project all files for this package will be published. For this package, it's only a migration. Run php artisan migrate to migrate the table. There will now be an options table in your database.

Usage

With the get_option() helper, we can get options, and with set_option() helper, we can set an option value.

// Get option
get_option('someKey');

// Get option, with a default fallback value if the key doesn't exist
get_option('someKey', 'Some default value if the key is not found');

// Set option
set_option(['someKey' => 'someValue']);


// Check the option exists
option_exists('someKey');

If you want to check if an option exists, you can use the facade:

use Option;

$check = Option::exists('someKey');

Contributing

Contributions are welcome, thanks to y'all :)

About Forwardcode Techstudio

Forwardcode Techstudio is a service based offshore development team focused on building secure, robust & scalable softwares.

License

The MIT License (MIT). Please see License File for more information.