PHP code example of cloudcake / laravel-settings

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

    

cloudcake / laravel-settings example snippets


php artisan vendor:publish --provider="Settings\Providers\SettingsServiceProvider" \
                           --tag="migrations"

use Settings\Traits\HasSettings;

class User extends Model
{
    use HasSettings;
}

use Settings\Models\Setting;

Setting::make('config', [
  'rateLimit' => true,
  'ipLocks'   => [
    '127.0.0.1',
    '10.0.0.1'
  ]
]);

use Settings\Models\Setting;

Setting::make('preferences', [
  'notifications'    => true,
  'backgroundColour' => '#ffffff'
], \App\User::class);

\App\User::find(1)->attachSetting('preferences', [
  'notifications' => false,
]);

\App\User::first()->setting('preferences');

\App\User::first()->setting('preferences')->get('notifications');

\App\User::first()->setting('preferences')->set('notifications', true);