Richo
Richo

Reputation: 1

unsolved error exception in laravel 5

I am currently following laravel tutorial in youtube, and now I am stuck in this error

can you guys help me solve this problem ? thanks in advance :)

ErrorException in UrlGenerator.php line 296: Route [profile.index] not defined. (View: C:\Users\user\Desktop\belajarlaravel\resources\views\templates\partials\navigation.blade.php) (View: C:\Users\user\Desktop\belajarlaravel\resources\views\templates\partials\navigation.blade.php) (View: C:\Users\user\Desktop\belajarlaravel\resources\views\templates\partials\navigation.blade.php)

this is my route :

<?php


Route::get('/',[
  'uses'=>'\Chatty\Http\Controllers\HomeController@index',
  'as'=>'home',
]
);

Route::get('/signup',[
  'uses'=>'\Chatty\Http\Controllers\AuthController@getSignup',
  'as'=>'auth.signup',
  'middleware'=>['guest'],
]
);

Route::post('/signup',[
  'uses'=>'\Chatty\Http\Controllers\AuthController@postSignup',
  'as'=>'auth.postSignup',
  'middleware'=>['guest'],
]
);

Route::get('/signin',[
  'uses'=>'\Chatty\Http\Controllers\AuthController@getSignin',
  'as'=>'auth.signin',
  'middleware'=>['guest'],
]
);

Route::post('/signin',[
  'uses'=>'\Chatty\Http\Controllers\AuthController@postSignin',
  'as'=>'auth.postSignin',
  'middleware'=>['guest'],
]
);

Route::get('/signout',[
  'uses'=>'\Chatty\Http\Controllers\AuthController@getSignout',
  'as'=>'auth.signout',
]
);

Route::get('/search',[
  'uses'=>'\Chatty\Http\Controllers\SearchController@getResults',
  'as'=>'search.results',
]
);

Route::get('/user/{username}',[
  'uses'=>'\Chatty\Http\Controllers\ProfileController@getProfile',
  'as'=>'profile.index',
]
);


Route::get('/profile/edit',[
  'uses'=>'\Chatty\Http\Controllers\ProfileController@getEdit',
  'as'=>'profile.edit',
  'middleware'=>['auth'],
]
);

Route::get('/user/{username}',[
  'uses'=>'\Chatty\Http\Controllers\ProfileController@postEdits',
  'middleware'=>['auth'],
]
);

and this is the navigation.blade

 @endif
 <ul class="nav navbar-nav navbar-right">
     @if(Auth::check())
         <li><a href="{{route('profile.index', [
             'username' => Auth::user()->username
         ]) }}">{{Auth::user()->getNameorUsername()}}</a></li>
         <li><a href="{{route('profile.edit')}}">Update profile</a></li>
         <li><a href="{{route('auth.signout')}}">Sign out</a></li>
     @else
         <li><a href="{{route('auth.signup')}}">Sign up</a></li>
         <li><a href="{{route('auth.signin')}}">Sign in</a></li>
     @endif
 </ul>

Upvotes: 0

Views: 69

Answers (1)

Pete Houston
Pete Houston

Reputation: 15079

You've got 2 duplicate routes, by nature, the last one overrides all the previous,

Route::get('/user/{username}',[
  'uses'=>'\Chatty\Http\Controllers\ProfileController@getProfile',
  'as'=>'profile.index',
]
);

...
// this one is the last
Route::get('/user/{username}',[
  'uses'=>'\Chatty\Http\Controllers\ProfileController@postEdits',
  'middleware'=>['auth'],
]

Each route should be unique, absolutely unique.

Upvotes: 1

Related Questions