generated from boboko/starter
43 lines
1.9 KiB
PHP
43 lines
1.9 KiB
PHP
{{--
|
|
@include('checkout::partials.line-custom-fields', ['line' => $line])
|
|
|
|
A cart or order line's custom-field answers (meta.custom_fields, written by
|
|
CartController::customFieldsMeta()) — label/value pairs. A file answer links
|
|
to the file through a temporary signed URL (CustomFieldFileController),
|
|
minted fresh on every render, with a thumbnail when the browser can display
|
|
the format (HEIC can't be shown outside Safari, so it gets the name only).
|
|
--}}
|
|
@php
|
|
$fields = $line->meta['custom_fields'] ?? [];
|
|
$previewable = ['image/jpeg', 'image/png', 'image/webp', 'image/gif'];
|
|
@endphp
|
|
|
|
@if (! empty($fields))
|
|
<dl class="bbk-line-fields">
|
|
@foreach ($fields as $field)
|
|
<div class="bbk-line-field">
|
|
<dt>{{ $field['label'] }}</dt>
|
|
<dd>
|
|
@if ($field['type'] === 'file')
|
|
@php
|
|
$fileUrl = \Illuminate\Support\Facades\URL::temporarySignedRoute(
|
|
'checkout.custom-field-file',
|
|
now()->addHours(2),
|
|
['locale' => app()->getLocale(), 'disk' => $field['disk'], 'path' => $field['path']],
|
|
);
|
|
@endphp
|
|
<a href="{{ $fileUrl }}" class="bbk-line-field-file" target="_blank" rel="noopener">
|
|
@if (in_array($field['mime'] ?? null, $previewable, true))
|
|
<img src="{{ $fileUrl }}" alt="" width="40" height="40" loading="lazy">
|
|
@endif
|
|
<span>{{ $field['value'] }}</span>
|
|
</a>
|
|
@else
|
|
{{ $field['value'] }}
|
|
@endif
|
|
</dd>
|
|
</div>
|
|
@endforeach
|
|
</dl>
|
|
@endif
|