https://github.com/appstract/laravel-options
Global key-value store in the database
https://github.com/appstract/laravel-options
database key-value laravel laravel-package options
Last synced: 29 days ago
JSON representation
Global key-value store in the database
- Host: GitHub
- URL: https://github.com/appstract/laravel-options
- Owner: appstract
- License: mit
- Created: 2017-03-02T23:41:37.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-03T12:17:50.000Z (11 months ago)
- Last Synced: 2024-10-29T21:50:28.522Z (6 months ago)
- Topics: database, key-value, laravel, laravel-package, options
- Language: PHP
- Homepage:
- Size: 72.3 KB
- Stars: 724
- Watchers: 18
- Forks: 65
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Options
[](https://packagist.org/packages/appstract/laravel-options)
[](https://packagist.org/packages/appstract/laravel-options)
[](LICENSE.md)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:
```bash
composer require appstract/laravel-options
```### Publish, migrate
By running `php artisan vendor:publish --provider="Appstract\Options\OptionsServiceProvider"` 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 `option()` helper, we can get and set options:
```php
// 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']);// Remove option
option()->remove('someKey');// Check the option exists
option_exists('someKey');
```If you want to check if an option exists, you can use the facade:
```php
use Option;$check = Option::exists('someKey');
```The helpers are available as Blade directives:
```php
@option('someKey')@option('someKey', 'Default value')
@optionExists('someKey')
// Code
@endif
```### Console
It is also possible to set options within the console:
```bash
php artisan option:set {someKey} {someValue}
```## Testing
```bash
$ composer test
```## Contributing
Contributions are welcome, [thanks to y'all](https://github.com/appstract/laravel-options/graphs/contributors) :)
## About Appstract
Appstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on [Medium](https://medium.com/appstract). You can [follow us on Twitter](https://twitter.com/teamappstract), [buy us a beer](https://www.paypal.me/teamappstract/10) or [support us on Patreon](https://www.patreon.com/appstract).
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.