PHP code example of bavix / laravel-settings

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

    

bavix / laravel-settings example snippets


use Bavix\Settings\Traits\HasSettings;
use Bavix\Settings\Traits\HasSetSettings;
use Bavix\Settings\Traits\HasGetSettings;
use Bavix\Settings\Interfaces\Settingable;

class User extends Model implements Settingable
{
    use HasGetSettings, HasSetSettings, HasSettings;
}

$user = User::first();
$user->getSetting('notify'); // null
$user->getSettingBool('notify'); // null
$user->getSettingBool('notify', false); // bool(false)

(bool)$user->setSettingBool('notify', false); // bool(true)
$user->getSettingBool('notify', false); // bool(false)