Search code examples
laravellaravel-bladeadminlte

In Laravel Blade, how to replace URL with route in search results of "sidebar-search" AdminLte v.3


I am using Laravel 8 with blade template and AdminLte v3. I added "sidebar-search" to the menu to search for menus and it worked. i read from adminLte Sidebar docs here https://adminlte.io/docs/3.1/javascript/sidebar-search.html

but the problem is: In the search results, the URL displayed is wrong, so when clicked, it displays 404 not found.

Here is the code on Blade:

<div class="form-inline">
    <div class="input-group" data-widget="sidebar-search">
        <input class="form-control form-control-sidebar bg-white" type="search"
            placeholder="Cari menu" aria-label="Search">
        <div class="input-group-append">
            <button class="btn btn-sidebar bg-white">
                <i class="fas fa-search fa-fw text-primary"></i>
            </button>
        </div>
    </div>
</div>

Here is the code for the menu I use:

<li class="nav-item">
    <a href="{{ route('notifikasi.index') }}"
        class="nav-link <?= request()->routeIs('notifikasi.*') ? 'active text-primary' : '' ?>">
        <i class="nav-icon far fa-circle"></i>
        <p>
            Notifikasi
        </p>
    </a>
</li>

<li class="nav-item">
    <a href="{{ route('logs') }}" class="nav-link <?= request()->routeIs('logs*') ? 'active text-primary' : '' ?>">
        <i class="nav-icon far fa-circle"></i>
        <p>
            Aktivitas
        </p>
    </a>
</li>

Here are the search results:

enter image description here

Here is the generated URL Link Result:

http://abcx.com/http%3A//abcx.com/posting

URL Result I want :

http://abcx.com/posting

How do I correct the URL of the search results? I tried to change adminlte.js, but it doesn't work


Solution

  • "Finally Solved! It turns out it's very simple, no need to add jquery or javascript, just change the route name script."

    From:

    <a href="{{ route('statistik.database') }}" class="nav-link">
    <p>Menu 1</p>
    </a>
    

    To:

    <a href="{{ route('statistik.database', [], false) }}" class="nav-link">
    <p>Menu 1</p>
    </a>