Search code examples
authenticationrouteslaravel-8multi-userlaravel-jetstream

Route [murid.index] not defined. (View: D:\xampp\htdocs\MentorOnlinemu\resources\views\navigation-menu.blade.php)


I've code in file navigation-menu.blade.php

@if (auth()->user()->role_id == 2)
                        
<x-jet-nav-link href="{{ route('murid.index') }}" :active="request()->routeIs('murid.index')">
                            
{{ __('Murid') }}
                        
</x-jet-nav-link>

@endif

and my code in routes/web.php

Route::group(['middleware' => 'auth'], function() {
    Route::group(['middleware' => 'role:murid', 'prefix' => 'murid', 'as' => 'murid.'], function() {
        Route::resource('murid', \App\Http\Controllers\MuridController::class);
    });
});

But, i got error Route [murid.index] not defined. From file navigation-menu.blade {{ route('murid.index') }} can't define. i already define in routes/web.php.

What's wrong with my code ?

Anyone can help me ? Thanks


Solution

  • If you have prefix "murid" and resource is "murid", then you must call the route like

    href="{{ route('murid.murid.index') }}"
    

    That must fix the issue.