@props([ 'value' => null, 'required' => null, ]) @php $raw = $value !== null ? trim((string) $value) : null; $hasTrailingStar = is_string($raw) && (bool) preg_match('/\s*\*+\s*$/', $raw); $hasTrailingOptional = is_string($raw) && (bool) preg_match('/\s*\(optional\)\s*$/i', $raw); $clean = $raw; if (is_string($clean) && $hasTrailingStar) { $clean = trim((string) preg_replace('/\s*\*+\s*$/', '', $clean)); } if (is_string($clean) && $hasTrailingOptional) { $clean = trim((string) preg_replace('/\s*\(optional\)\s*$/i', '', $clean)); } $isRequired = $required; if ($isRequired === null) { if ($hasTrailingStar) { $isRequired = true; } elseif ($hasTrailingOptional) { $isRequired = false; } } else { $isRequired = filter_var($required, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); if ($isRequired === null) { $isRequired = $required === true || $required === 1 || $required === '1'; } } @endphp