The
data_get
function retrieves a value from a nested array or object using "dot" notation:<?php $data = ['products' => ['desk' => ['price' => 100]]];
$price = data_get($data, 'products.desk.price');
<?php 'id' => $package['name'],
'slug' => $statamic['slug'] ?? null,
'editions' => $statamic['editions'] ?? [],
'marketplaceId' => data_get($marketplaceData, 'id', null),
'marketplaceSlug' => data_get($marketplaceData, 'slug', null),
'marketplaceUrl' => data_get($marketplaceData, 'url', null),
'marketplaceSellerSlug' => data_get($marketplaceData, 'seller', null),
<?php 'slug' => $statamic['slug'] ?? null,
'editions' => $statamic['editions'] ?? [],
'marketplaceId' => data_get($marketplaceData, 'id', null),
'marketplaceSlug' => data_get($marketplaceData, 'slug', null),
'marketplaceUrl' => data_get($marketplaceData, 'url', null),
'marketplaceSellerSlug' => data_get($marketplaceData, 'seller', null),
'latestVersion' => data_get($marketplaceData, 'latest_version', null),
<?php 'editions' => $statamic['editions'] ?? [],
'marketplaceId' => data_get($marketplaceData, 'id', null),
'marketplaceSlug' => data_get($marketplaceData, 'slug', null),
'marketplaceUrl' => data_get($marketplaceData, 'url', null),
'marketplaceSellerSlug' => data_get($marketplaceData, 'seller', null),
'latestVersion' => data_get($marketplaceData, 'latest_version', null),
'version' => Str::removeLeft($package['version'], 'v'),
<?php 'marketplaceId' => data_get($marketplaceData, 'id', null),
'marketplaceSlug' => data_get($marketplaceData, 'slug', null),
'marketplaceUrl' => data_get($marketplaceData, 'url', null),
'marketplaceSellerSlug' => data_get($marketplaceData, 'seller', null),
'latestVersion' => data_get($marketplaceData, 'latest_version', null),
'version' => Str::removeLeft($package['version'], 'v'),
'namespace' => $namespace,
<?php 'marketplaceSlug' => data_get($marketplaceData, 'slug', null),
'marketplaceUrl' => data_get($marketplaceData, 'url', null),
'marketplaceSellerSlug' => data_get($marketplaceData, 'seller', null),
'latestVersion' => data_get($marketplaceData, 'latest_version', null),
'version' => Str::removeLeft($package['version'], 'v'),
'namespace' => $namespace,
'autoload' => $autoload,
<?php return collect($value)->reduce(function ($carry, $value) use ($key) {
if ($key) {
$value = data_get($value, $key);
}
$value = $value instanceof Value ? $value->value() : $value;