https://github.com/emresari89/laravel-options
https://github.com/emresari89/laravel-options
database global-options laravel settings site-settings
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/emresari89/laravel-options
- Owner: emresari89
- License: mit
- Created: 2021-03-07T06:52:45.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-06T04:47:53.000Z (over 1 year ago)
- Last Synced: 2025-05-30T16:27:49.461Z (about 1 year ago)
- Topics: database, global-options, laravel, settings, site-settings
- Language: PHP
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Options
[](https://packagist.org/packages/emresari89/laravel-options)
[](https://packagist.org/packages/emresari89/laravel-options)
[](LICENSE.md)
[](https://travis-ci.org/emresari89/laravel-options)
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 emresari89/laravel-options
```
### Publish, migrate
By running `php artisan vendor:publish --provider="Emresari\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 all options
options();
// Get option by id
optionID($id);
// 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']);
// Set option with type (type 1 default)
option_type(['someKey' => 'someValue'],null,2);
// 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');
```
### Console
It is also possible to set options within the console:
```bash
php artisan option:set {someKey} {someValue}
```
## Testing
```bash
$ composer test
```
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.