PHP code example of shishima / dynamic-view-value-render

1. Go to this page and download the library: Download shishima/dynamic-view-value-render 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/ */

    

shishima / dynamic-view-value-render example snippets


    return [
        'delivery_date' => [
            'type' => [\Shishima\ConvertExport\Pipeline\DB::class],
            'value' => 'location.name'
            ]
        ];
        ...
    

    $data = [
        'estimate' => $estimate,
        'company' => $company
   ]

    dynamic_render_set_data(data: $data); // <-- Here
   
    return view($view, ...));
    

    $data = compact('estimate', 'company');

    dynamic_render_set_data(data: $data);  // <-- Here

    return view($view, ...));
    

    'delivery_date' => [
        'type' => [\Shishima\ConvertExport\Pipeline\DB::class],
        'value' => 'location.city.name'
        ]
    ];
   

    'delivery_date' => [
        'type' => [\Shishima\ConvertExport\Pipeline\Fixed::class],
        'value' => 'Hello world!'
        ]
    ];
   

namespace App\Transform;

use Illuminate\Support\Arr;
use Shishima\ConvertExport\Pipeline\ConvertExportBase;

class UpperCase extends ConvertExportBase
{
    public function __invoke($payload) {
        $value = Arr::get($payload, 'value', '');
        $dataInput = Arr::get($payload, 'dataInput');
        $config = Arr::get($payload, 'config');

        // transform value
        return strtoupper($value);
    }
}

'delivery_date' => [
    'type' => [
        \Shishima\ConvertExport\Pipeline\Fixed::class,
        \App\Transform\UpperCase::class,
    ],
    'value' => 'Hello world!'
    ]
];

namespace App\Transform;

use Illuminate\Support\Arr;
use Shishima\ConvertExport\Pipeline\ConvertExportBase;

class Transform extends ConvertExportBase
{
    public function convertUpper($payload) {
        // ...
    }
    
    public function convertLower($payload) {
        // ...
    }
}

'delivery_date' => [
    'type' => [
        '\App\Transform\Transform:Upper,Lower',
    ],
    'value' => ''
    ]
];