PHP code example of ehsanmoradi / data-mapper

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

    

ehsanmoradi / data-mapper example snippets




return [
    'default' => [
        'name'         => 'first_name',
        'family'       => 'last_name',
        'birthdayDate' => 'birthday',
    ],

  // ...
];

use EhsanMoradi\DataMapper\Mapper;
use Illuminate\Support\Facades\Http;

$data = Http::get('/api/json')->body();

$mapper = new Mapper($data);
// or
$mapper = new Mapper($data, config('data-mapper.nested'));

dd([
    $mapper->name(),
    $mapper->family(),
    $mapper->birthdayDate(),
]);




return [
    'nested' => [
        'plate'              => 'plate',
        ''brick.each.examine',
        'brickEachSoil'      => 'brick.each.soil',
        'brickEachSpeed'     => 'brick.each.speed',
        'brickEachTherefore' => 'brick.each.therefore',
        'brickEachLearn'     => 'brick.each.learn',
        'brickPeriod'        => 'brick.period',
        'brickEntirely'      => 'brick.entirely',
        'brickDevelop'       => 'brick.develop',
        'brickWeek'          => 'brick.week',
        'brickWent'          => 'brick.went',
        'win'                => 'win',
        'lay'                => 'lay',
        'beat'               => 'beat',
    ],
   // ...
];

php artisan vendor:publish --tag=data-mapper