{{--Start new image container--}} @php /** * @var $item_value */ $item_file_number = $item_file_number ?? 1; $parent_class = $parent_class ?? 'col-lg-12'; $validExtensions = (isset($validExtensions) && is_array($validExtensions)) ? 'data-valid-extensions='.implode(',', $validExtensions) : ''; //$validExtensions are array $isFileExists = $item_value && file_exists(public_path('storage/'.$item_value)); $hideFileContainer = isset($readOnlyFields) && $readOnlyFields === true && !$isFileExists; $showFileLabel = !isset($readOnlyFields) || $readOnlyFields === false; //$errorKey = preg_replace('/\[(\w+)\]/', '.$1', $input_name ?? ''); // w => [a-z, A-Z, 0-9, _] //Allows any character except ] // () capture group - $0 The entire match, $1 first group $errorKey = preg_replace('/\[([^\]]+)\]/', '.$1', $input_name ?? ''); // Convert questions[0][answers][1][text] → questions.0.answers.1.text @endphp @if(!$hideFileContainer)
@if($isFileExists) @endif
@if($showFileLabel) @endif
@endif {{--End new image container--}}