PHP code example of bonk007 / system-settings

1. Go to this page and download the library: Download bonk007/system-settings library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bonk007 / system-settings example snippets


settings()->set('<group>.<key>', <value>);

settings()->set('global-settings.maintenance_scheduled_at', Carbon::parse('2024-07-01 00:00:00'));

settings()->for(<model instance>)
  ->set('<group>.<key>', <value>);

settings()->for(\App\Models\Organization::find(6))
  ->set('invoice.number_format', 'INV/{SEQUENCE}/{MONTH}/{YEAR}');

settings()->set('<group>.<key>.<table of configurable model>.<primary key>', <value>);

settings()->set('invoice.number_format.organizations.6', 'INV/{SEQUENCE}/{MONTH}/{YEAR}');

settings('<group>.<key>', <default value>);

settings()->for(<configurable model>)
  ->get('<group>.<key>', <default value>);

settings('<group>.<key>.<table of configurable model>.<primary key>', <default value>)

settings('global-settings.maintenance_scheduled_at');
settings('invoice.number_format.organizations.6');
settings()->for(\App\Models\Organization::find(6))
  ->get('invoice.number_format');

settings->unset('<group>.<key>')

settings->unset('<group>.<key>.<table of configurable model>.<primary key>')

settings()->for(<configurable model>)
  ->unset('<group>.<key>');

settings()->unset('global-settings.maintenance_scheduled_at');
settings()->unset('invoice.number_format.organizations.6');
settings()->for(\App\Models\Organization::find(6))
  ->unset('invoice.number_format');

class User extends Model implements Configurable
{
  // ...
}

php artisan migrate