https://github.com/mlk9/setting-laravel
Setting (encryption) for Laravel
https://github.com/mlk9/setting-laravel
laravel laravel-package setting
Last synced: about 2 months ago
JSON representation
Setting (encryption) for Laravel
- Host: GitHub
- URL: https://github.com/mlk9/setting-laravel
- Owner: mlk9
- License: mit
- Created: 2021-09-12T02:48:18.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-09T09:26:16.000Z (about 2 years ago)
- Last Synced: 2025-08-02T03:58:19.755Z (7 months ago)
- Topics: laravel, laravel-package, setting
- Language: PHP
- Homepage:
- Size: 109 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Setting Laravel
Setting (encryption) for Laravel saving database
Encryption docs https://laravel.com/docs/encryption
Hash Salts Method
## Requirement
- Laravel 6+
- PHP +8.2
## Installation
- via composer
```sh
composer require mlk9/setting-laravel
```
- vendor publish
```sh
php artisan vendor:publish --tag=setting-laravel
```
- migrate table
```sh
php artisan migrate
```
## Usage
set data
```sh
Setting::set('KEY_NAME','VALUE');
//or
Setting::set([
'KEY_NAME' => 'VALUE',
'KEY_NAME' => 'VALUE'
]);
```
get data
```sh
Setting::get('KEY_NAME','DEFAULT_VALUE',$salts = []);
```
key exist
```sh
Setting::exists('KEY_NAME'); //output : bool
```
destroy data
```sh
Setting::destroy('KEY_NAME');
```
destroy all data
```sh
Setting::destroyAll();
```
get all data
```sh
Setting::all();
```
refresh salts
```sh
Setting::refreshSalts();
```
when you need change salts, you can use this method for replace old salts to new configure package
```sh
Setting::changeOldSalts(array $oldSalts);
```
### config using
#### Method 1 (recommended)
replace all config data with setting data
```sh
//must be same key name
Setting::set(['app.name' => 'Maleki']);
//uses at \app\Providers\AppServiceProvider.php in boot
Setting::replaceAllConfigs();
```
#### Method 2 (customize)
replace custom config data with setting data
```sh
//in page save
Setting::set(['seo.site.name' => 'Maleki']);
//uses at \app\Providers\AppServiceProvider.php in boot
Setting::replaceConfigs(['app.name' => 'seo.site.name']);
//for test
config('app.name') // return : Maleki
```
#### Method 3 (not recommended)
`app\Providers\AppServiceProvider.php`
```sh
public function boot()
{
Config::set('services.example.exam1',Setting::get('example.exam'));
}
```