PHP code example of lysice / hyperf-user-settings

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

    

lysice / hyperf-user-settings example snippets


return array(
  'table' => 'users',
  'column' => 'settings',
  'constraint_key' => 'id',
  'default_constraint_value' => null,
  'custom_constraint' => null,
);

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

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

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

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

setting($userId)->all($constraint_value);

setting($userId)->save($constraint_value);

setting($userId)->load($constraint_value);

setting($userId)->set('key', 'value', constraint_value)->get('key', 'default');

// Set 'example' setting to 'hello world' and save to db
setting($userId)->set('example', 'hello world')->save();

// or use like:
$setting = setting($userId);
$setting->set('example', 'hello world')
$setting->save();

// Get the same setting
return setting($userId)->get('example');