PHP code example of akosnoavek / models-data-extractor
1. Go to this page and download the library: Download akosnoavek/models-data-extractor 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/ */
akosnoavek / models-data-extractor example snippets
return [
// Custom base classes that should be treated as a single Eloquent model
// when resolved through a section's "root" (see below).
'model_classes' => [],
// Default format used to render fields declared with "date" => true.
'date_format' => 'd/m/Y',
];
use AkosNoavek\DataExtractor\Facades\DataExtractor;
$array = DataExtractor::make($target)->toArray(data: $schema);
[
"path" => "field_one", // equired — human-readable label used in output
"date" => false, // optional — format the value as a date (d/m/Y)
"view" => null, // optional — Blade view name for custom HTML rendering
"evaluate_when_empty" => true, // optional — keep the field even if its value is empty
"extra_attributes" => null, // optional — arbitrary array passed through to the output/view
]