35 lines
1021 B
PHP
35 lines
1021 B
PHP
@props(['link', 'class' => ''])
|
|
|
|
@php
|
|
$href = '';
|
|
$spa = true;
|
|
|
|
// Determine the href based on link type
|
|
if (isset($link['direct_url'])) {
|
|
// Custom path or external URL
|
|
$href = $link['direct_url'];
|
|
$spa = false; // Disable SPA for custom URLs
|
|
} elseif (isset($link['route'])) {
|
|
// Laravel route
|
|
try {
|
|
$href = route($link['route'], $link['params'] ?? []);
|
|
} catch (\Exception $e) {
|
|
// If route doesn't exist, skip this link
|
|
$href = '#';
|
|
}
|
|
} else {
|
|
$href = '#'; // Fallback
|
|
}
|
|
@endphp
|
|
|
|
@if($href !== '#')
|
|
<a href="{{ $href }}"
|
|
{{ $attributes->merge(['class' => 'flex flex-row items-center gap-2 text-sm font-semibold text-wrap ' . $class . ' ' . ($href === request()->url() ? 'text-primary' : 'text-base hover:text-base/80')]) }}
|
|
@if($spa) wire:navigate @endif>
|
|
@if(isset($link['icon']))
|
|
<i class="{{ $link['icon'] }}"></i>
|
|
@endif
|
|
{{ $link['name'] }}
|
|
</a>
|
|
@endif
|