PHP code example of signifly / laravel-configurable
1. Go to this page and download the library: Download signifly/laravel-configurable 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/ */
signifly / laravel-configurable example snippets
// Remember to add use statement
use Signifly\Configurable\Configurable;
class User
{
use Configurable;
// Remember to make `config` fillable
protected $fillable = [
'config',
];
// Remember to add `config` to casts
protected $casts = [
'config' => 'array',
];
}
Schema::table('users', function (Blueprint $table) {
$table->json('config')->nullable();
});
// Remember to add use statement
use Signifly\Configurable\Configurable;
class User
{
use Configurable;
// Remember to make `settings` fillable
protected $fillable = [
'settings', 'extras',
];
// Remember to add `settings` to casts
protected $casts = [
'settings' => 'array',
'extras' => 'array',
];
protected function getConfigKey()
{
return 'settings';
}
// or add a custom config attribute like this:
public function getExtrasAttribute()
{
return new Config($this, 'extras');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.