PHP code example of thinktomorrow / dynamic-attributes

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

    

thinktomorrow / dynamic-attributes example snippets


$model->isDynamic('firstname'); // true
$model->isDynamic('xxx'); // false
 
$model->rawDynamicValues() // outputs the entire array: ['firstname' => 'Ben']
 php
// Setting a dynamic attribute just like a regular attribute.
$model = new ExampleModel(['firstname' => 'Ben']);

// .. or by setting it after instantiation
$model->firstname = 'Ben';

// Is the same as
$model->setDynamic('firstname', 'Ben');
 php
// You can use dot syntax
$model->setDynamic('title.en', 'My article title');
$model->setDynamic('title.nl', 'Mijn blogtitel');

// Optionally pass the locale as third argument
$model->setDynamic('title', 'My article title', 'en');