【发布时间】:2016-10-20 18:05:06
【问题描述】:
我的路线有问题,我有我的路线:
Route::get('dashboard/password', 'UserController@password');
Route::post('dashboard/updatepassword', 'UserController@updatePassword');
// PAGINA UTENTE PUBBLICA
Route::get('/{username}', 'FrontController@user');
// blog routes
Route::get('blog', 'FrontController@blog');
Route::get('blog/{slug}', 'FrontController@article');
Route::get('blog/category/{name}', 'FrontController@BlogCategory');
Route::get('blog/tag/{name}', 'FrontController@tags');
Route::resource('comment', 'CommentController');
还有我的 FrontController:
public function blog()
{
$articles = Article::OrderBy('id','DESC')->paginate(3);
$Allarticles = Article::OrderBy('id','DESC')->get();
$Allcategories = BlogCategory::OrderBy('id','DESC')->get();
$Alltags = Tag::OrderBy('id','DESC')->get();
$Allcomments = Comment::OrderBy('id','DESC')->take(3)->get();
return view('blog', compact('articles','Alltags','Allarticles','Allcategories','Allcomments'));
}
如果我转到“http://localhost:8000/blog”,它会返回到我之前所在的页面。类似于 route->back()。
我不知道为什么我会遇到这个问题,其他博客路由都很好。
我做了一些这样的测试:
public function blog()
{
return "Hi";
}
它不返回“Hi”,所以我认为是路线的问题。我这里没有可用的中间件,我的博客/文章等其他路由运行良好。
【问题讨论】:
-
你的 blog.blade.php 的完整路径是什么?您是否可能用另一条路线覆盖该路线?尝试将您的路线放在您的 routes.php 的最顶部
-
views/blog.blade.php 这是完整路径,我没有使用文件夹,我不知道为什么但不起作用。如果我要去一条不存在的路线,我也会遇到同样的问题。
-
问题是:Route::get('/{username}', 'FrontController@user');我删除了,它可以工作
标签: php laravel laravel-5.1