recovery men recovery men - 1 month ago 13
PHP Question

Route [user.profile] not defined. Laravel 5.3

I want to go on profile page but getting error route not defined.I tried to define route but still there
I defined a new function in User resourceController as profile
and i am defining my route in this way

Route::get('user/profile', 'UserController@profile');
Route::resource('/user', 'UserController');


Here is my Header through which i am going to profile page

<li>
<a href="{{route('user.profile')}}">
<i class="icon-user"></i> My Profile </a>
</li>


Here User is name of folder and profile is page inside it

Here is method in UserController

public function profile($request)
{
return ('Here');
return view('user.profile');
}


I was testing but its not coming in profile method

Answer

You're trying to use named route, so you need to set a name for it:

Route::get('user/profile', ['as' => 'user.profile', 'uses' => 'UserController@profile']);

Or:

Route::get('user/profile', 'UserController@profile')->name('user.profile');

If you don't want to use named route, you can use url() instead of route():

<a href="{{ url('user/profile') }}">
Comments