PHP code example of rezkonline / laravel-user-settings

1. Go to this page and download the library: Download rezkonline/laravel-user-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/ */

    

rezkonline / laravel-user-settings example snippets


return [
  'table' => 'users',
  'column' => 'settings',
  'constraint_key' => 'id',
  'default_constraint_value' => null,
  'custom_constraint' => null,
];

Setting::set('key', 'value', $constraint_value);
setting()->set('key', 'value', $constraint_value);

Setting::get('key', 'default', $constraint_value);
setting()->get('key', 'default', $constraint_value);
setting('key', 'default', $constraint_value);

Setting::forget('key', $constraint_value);
setting()->forget('key', $constraint_value);

Setting::has('key', $constraint_value);
setting()->has('key', $constraint_value);

Setting::all($constraint_value);
setting()->all($constraint_value);

Setting::save($constraint_value);
setting()->save($constraint_value);

Setting::load($constraint_value);
setting()->load($constraint_value);

// Set 'example' setting to 'hello world'
Setting::set('example', 'hello world');

// Save to database
Setting::save();

// Get the same setting
return Setting::get('example');

// Set 'example' setting to 'hello world'
Setting::set('example', 'hello world', 23);

// Save to database
Setting::save(23);

// Get the same setting
return Setting::get('example', null, 23);
bash
php artisan vendor:publish --provider="Rezkonline\LaravelUserSettings\ServiceProvider" --tag="config"
bash
php artisan vendor:publish --provider="Rezkonline\LaravelUserSettings\ServiceProvider" --tag="migrations"
bash
php artisan migrate