riipandi / laravel-opsi
Put your Laravel application settings in database.
Requires
- php: >=7.2.1
- illuminate/database: ^5.8|^6.0
- illuminate/support: ^5.8|^6.0
Requires (Dev)
- orchestra/database: ^4.2
- orchestra/testbench: ~4.6
This package is auto-updated.
Last update: 2024-11-20 19:26:43 UTC
README
Put your Laravel application settings in database
Quick Start
To get started with laravel-options, use Composer to add the package to your project's dependencies:
composer require appstract/laravel-options
Publish, migrate
By running php artisan vendor:publish --provider="Riipandi\LaravelOpsi\OptionsServiceProvider"
in your project all files for this package will be published.
For this package, it's only has a migration.
Run php artisan migrate
to migrate the table.
There will now be an options
table in your database.
Usage
With the option()
helper, we can get and set options:
// Get option option('someKey'); // Get option, with a default fallback value if the key doesn't exist option('someKey', 'Some default value if the key is not found'); // Set option 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');
Setting a value to a key that already exists will overwrite the value.
Console
It is also possible to set options within the console:
php artisan option:set {someKey} {someValue}
Testing
$ composer test
Contributing
Contributions are welcome, thanks to y'all :)
License
The MIT License (MIT). Please see License File for more information.