laravel 5中未解决的错误异常

时间:2015-12-11 17:44:48

标签: php laravel frameworks

我目前正在youtube上关注laravel教程,现在我陷入了这个错误

你能帮助我解决这个问题吗?提前谢谢:)

  

UrlGenerator.php第296行中的ErrorException:路由[profile.index]没有   定义。 (视图:   C:\用户\用户\桌面\ belajarlaravel \资源\意见\模板\谐音\ navigation.blade.php)   (视图:   C:\用户\用户\桌面\ belajarlaravel \资源\意见\模板\谐音\ navigation.blade.php)   (视图:   C:\用户\用户\桌面\ belajarlaravel \资源\视图\模板\泛音\ navigation.blade.php)

这是我的路线:

<?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'],
]
);

这是 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>

1 个答案:

答案 0 :(得分:1)

你有两条重复的路线,性质上,最后一条覆盖以前的所有路线,

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'],
]

每条路线都应该是唯一的,绝对独一无二。