PHP code example of glorand / laravel-model-settings
1. Go to this page and download the library: Download glorand/laravel-model-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/ */
glorand / laravel-model-settings example snippets
use Glorand\Model\Settings\Traits\HasSettings;
class User extends Model
{
use HasSettings;
}
class User extends Model
{
use HasSettings;
protected $settingsDriver = 'table'; // 'field' (default) | 'table' | 'redis' | 'cache'
}
public $settingsFieldName = 'user_settings';
use Glorand\Model\Settings\Traits\HasSettings;
class User extends Model
{
use HasSettings;
//define only if you select a different name from the default
public $settingsFieldName = 'user_settings';
//define only if the model overrides the default connection
protected $connection = 'mysql';
}
use Glorand\Model\Settings\Traits\HasSettings;
class User extends Model
{
use HasSettings;
protected $settingsDriver = 'table';
}
use Glorand\Model\Settings\Traits\HasSettings;
class User extends Model
{
use HasSettings;
protected $settingsDriver = 'redis';
}
use Glorand\Model\Settings\Traits\HasSettings;
class User extends Model
{
use HasSettings;
protected $settingsDriver = 'cache';
}
use Glorand\Model\Settings\SettingsManagerFactory;
app(SettingsManagerFactory::class)->extend('dynamodb', function ($model) {
return new DynamoDbSettingsManager($model);
});
return [
// start other config options
// end other config options
// defaultConfigs
'defaultSettings' => [
'users' => [
'key_1' => 'val_1',
]
]
];
use Glorand\Model\Settings\Traits\HasSettings;
class User extends Model
{
use HasSettings;
public $defaultSettings = [
'key_1' => 'val_1',
];
}