In my web.php containing my routes, I have the following Route:
JavaScript
x
Route::get('/profile', 'ProfileProfileController@index');
Which links to my Profile Controller
I am linking to this controller with
JavaScript
Route::get('/profile', 'ProfileProfileController@index');
However, when I navigate to the page with this route set, I get this error
JavaScript
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
JavaScript
<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:
JavaScript
Route::get('profile', [
'as' => 'profile',
'uses' => 'ProfileProfileController@index',
]);