skip to Main Content

I have a dynamic navigation (all names, icons, links, aand all other things comes from table).
But when I tried to use link I get error that Route [soon] not defined

                @foreach($categories as $item)
                    <li class="sidebar-dropdown">
                        <a class="fw-bold" href="javascript:void(0)"><i class="uil {{ $item->icon }} me-2 d-inline-block"></i>{{ $item->title }}</a>
                        <div class="sidebar-submenu">
                            @foreach($item['children'] as $child)
                                <ul>
                                    <li><a href="{{ route($child->link)}}">{{ $child->title }}</a></li>
                                </ul>
                            @endforeach
                        </div>
                    </li>
                @endforeach

web route code:

Route::prefix(config('admintw.prefix'))->middleware(['auth', 
'verified', 'activeUser', 'IpCheckMiddleware'])->group(function () {
     Route::get('soon', AppHttpLivewireAdminMiscellaneousComingsoon::class)->name('soon');
});

In the table’s link column there is "soon".

2

Answers


  1. The error message "Route [soon] not defined" means that Laravel is unable to find a named route with the name "soon". In your case, the issue is that the link column in your table is storing the literal string "soon" instead of the route name. To fix this, you need to modify the link column in your table to store the name of the route instead of the literal string.

    Assuming that the title of the navigation link is the same as the name of the route, you can modify your code like this:

    @foreach($item['children'] as $child)
        <ul>
            <li><a href="{{ route($child->title)}}">{{ $child->title }}</a></li>
        </ul>
    @endforeach
    
    Login or Signup to reply.
  2. php artisan tinker and check route('soon') and if you get an error, that means that route

    'verified', 'activeUser', 'IpCheckMiddleware'])->group(function () {
         Route::get('soon', AppHttpLivewireAdminMiscellaneousComingsoon::class)->name('soon');
    });
    

    wasn’t processed

    try with something simple like

    Route::get('soon', AppHttpLivewireAdminMiscellaneousComingsoon::class)->name('soon');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search