PHP code example of alariva / modelmerge

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

    

alariva / modelmerge example snippets


    $modelA = SampleModel::make(['firstname' => 'John', 'age' => 33]);
    $modelB = SampleModel::make(['firstname' => 'John', 'lastname' => 'Doe']);

    $mergedModel = ModelMerge::setModelA($modelA)->setModelB($modelB)->merge();

    $mergedModel->firstname; // John
    $mergedModel->lastname; // Doe
    $mergedModel->age; // 33