Skip to content
Advertisement

Laravel Route Link – Error Route not Defined

In my web.php containing my routes, I have the following Route:

Route::get('/profile', 'ProfileProfileController@index');

Which links to my Profile Controller
I am linking to this controller with

Route::get('/profile', 'ProfileProfileController@index');

However, when I navigate to the page with this route set, I get this error

    ErrorException (E_ERROR)
Route [profile] not defined. (View: D:MAMPhtdocsmilestoneexpresourcesviewslayoutsapp.blade.php) (View: D:MAMPhtdocsmilestoneexpresourcesviewslayoutsapp.blade.php)

However, the following code works fine with navigation when I switch from route to URL

<a class="dropdown-item" href="{{ url('profile') }}">{{ __('Profile') }}</a>

Why does URL work but not route? And how can I make my route work?
Laravel version 5.8.35

Advertisement

Answer

Alternatively you can also do it this way:

Route::get('profile', [
    'as' => 'profile',
    'uses' => 'ProfileProfileController@index',
]);
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement