{"id":13545639,"url":"https://github.com/akaunting/laravel-setting","last_synced_at":"2025-04-14T23:23:48.747Z","repository":{"id":45239417,"uuid":"101231817","full_name":"akaunting/laravel-setting","owner":"akaunting","description":"Persistent settings package for Laravel","archived":false,"fork":false,"pushed_at":"2024-03-13T09:12:19.000Z","size":94,"stargazers_count":490,"open_issues_count":3,"forks_count":66,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-11T21:12:03.129Z","etag":null,"topics":["akaunting","config","laravel","persistent","php","settings"],"latest_commit_sha":null,"homepage":"https://akaunting.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akaunting.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-23T22:59:04.000Z","updated_at":"2025-03-26T05:34:37.000Z","dependencies_parsed_at":"2024-06-18T11:28:55.838Z","dependency_job_id":null,"html_url":"https://github.com/akaunting/laravel-setting","commit_stats":{"total_commits":71,"total_committers":17,"mean_commits":4.176470588235294,"dds":0.3943661971830986,"last_synced_commit":"97e42cd18b6595169c3a5b8082d20f9585c9c512"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akaunting%2Flaravel-setting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akaunting%2Flaravel-setting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akaunting%2Flaravel-setting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akaunting%2Flaravel-setting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akaunting","download_url":"https://codeload.github.com/akaunting/laravel-setting/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248976273,"owners_count":21192361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["akaunting","config","laravel","persistent","php","settings"],"created_at":"2024-08-01T11:01:07.839Z","updated_at":"2025-04-14T23:23:48.728Z","avatar_url":"https://github.com/akaunting.png","language":"PHP","readme":"# Persistent settings package for Laravel\n\n[![Downloads](https://poser.pugx.org/akaunting/laravel-setting/d/total.svg)](https://github.com/akaunting/laravel-setting)\n[![StyleCI](https://styleci.io/repos/101231817/shield?style=flat\u0026branch=master)](https://styleci.io/repos/101231817)\n[![License](https://poser.pugx.org/akaunting/laravel-setting/license.svg)](LICENSE.md)\n\nThis package allows you to save settings in a more persistent way. You can use the database and/or json file to save your settings. You can also override the Laravel config.\n\n* Driver support\n* Helper function\n* Blade directive\n* Override config values\n* Encryption\n* Custom file, table and columns\n* Auto save\n* Extra columns\n* Cache support\n\n## Getting Started\n\n### 1. Install\n\nRun the following command:\n\n```bash\ncomposer require akaunting/laravel-setting\n```\n\n### 2. Register (for Laravel \u003c 5.5)\n\nRegister the service provider in `config/app.php`\n\n```php\nAkaunting\\Setting\\Provider::class,\n```\n\nAdd alias if you want to use the facade.\n\n```php\n'Setting' =\u003e Akaunting\\Setting\\Facade::class,\n```\n\n### 3. Publish\n\nPublish config file.\n\n```bash\nphp artisan vendor:publish --tag=setting\n```\n\n### 4. Database\n\nCreate table for database driver\n\n```bash\nphp artisan migrate\n```\n\n### 5. Configure\n\nYou can change the options of your app from `config/setting.php` file\n\n## Usage\n\nYou can either use the helper method like `setting('foo')` or the facade `Setting::get('foo')`\n\n### Facade\n\n```php\nSetting::get('foo', 'default');\nSetting::get('nested.element');\nSetting::set('foo', 'bar');\nSetting::forget('foo');\n$settings = Setting::all();\n```\n\n### Helper\n\n```php\nsetting('foo', 'default');\nsetting('nested.element');\nsetting(['foo' =\u003e 'bar']);\nsetting()-\u003eforget('foo');\n$settings = setting()-\u003eall();\n```\n\nYou can call the  `save()` method to save the changes.\n\n### Auto Save\n\nIf you enable the `auto_save` option in the config file, settings will be saved automatically every time the application shuts down if anything has been changed.\n\n### Blade Directive\n\nYou can get the settings directly in your blade templates using the helper method or the blade directive like `@setting('foo')`\n\n### Override Config Values\n\nYou can easily override default config values by adding them to the `override` option in `config/setting.php`, thereby eliminating the need to modify the default config files and also allowing you to change said values during production. Ex:\n\n```php\n'override' =\u003e [\n    \"app.name\" =\u003e \"app_name\",\n    \"app.env\" =\u003e \"app_env\",\n    \"mail.driver\" =\u003e \"app_mail_driver\",\n    \"mail.host\" =\u003e \"app_mail_host\",\n],\n```\n\nThe values on the left corresponds to the respective config value (Ex: config('app.name')) and the value on the right is the name of the `key` in your settings table/json file.\n\n### Encryption\n\nIf you like to encrypt the values for a given key, you can pass the key to the `encrypted_keys` option in `config/setting.php` and the rest is automatically handled by using Laravel's built-in encryption facilities. Ex:\n\n```php\n'encrypted_keys' =\u003e [\n    \"payment.key\",\n],\n```\n\n### JSON Storage\n\nYou can modify the path used on run-time using `setting()-\u003esetPath($path)`.\n\n### Database Storage\n\nIf you want to use the database as settings storage then you should run the `php artisan migrate`. You can modify the table fields from the `create_settings_table` file in the migrations directory.\n\n#### Extra Columns\n\nIf you want to store settings for multiple users/clients in the same database you can do so by specifying extra columns:\n\n```php\nsetting()-\u003esetExtraColumns(['user_id' =\u003e Auth::user()-\u003eid]);\n```\n\nwhere `user_id = x` will now be added to the database query when settings are retrieved, and when new settings are saved, the `user_id` will be populated.\n\nIf you need more fine-tuned control over which data gets queried, you can use the `setConstraint` method which takes a closure with two arguments:\n\n- `$query` is the query builder instance\n- `$insert` is a boolean telling you whether the query is an insert or not. If it is an insert, you usually don't need to do anything to `$query`.\n\n```php\nsetting()-\u003esetConstraint(function($query, $insert) {\n\tif ($insert) return;\n\t$query-\u003ewhere(/* ... */);\n});\n```\n\n### Custom Drivers\n\nThis package uses the Laravel `Manager` class under the hood, so it's easy to add your own storage driver. All you need to do is extend the abstract `Driver` class, implement the abstract methods and call `setting()-\u003eextend`.\n\n```php\nclass MyDriver extends Akaunting\\Setting\\Contracts\\Driver\n{\n\t// ...\n}\n\napp('setting.manager')-\u003eextend('mydriver', function($app) {\n\treturn $app-\u003emake('MyDriver');\n});\n```\n\n## Changelog\n\nPlease see [Releases](../../releases) for more information what has changed recently.\n\n## Contributing\n\nPull requests are more than welcome. You must follow the PSR coding standards.\n\n## Security\n\nIf you discover any security related issues, please email security@akaunting.com instead of using the issue tracker.\n\n## Credits\n\n- [Denis Duliçi](https://github.com/denisdulici)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakaunting%2Flaravel-setting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakaunting%2Flaravel-setting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakaunting%2Flaravel-setting/lists"}