dqnek0079 2018-10-21 15:11
浏览 319
已采纳

Laravel - 找不到您要查找的页面

I got page 404 when I click the link

I don't know which part is wrong, can someone help me?

sidenav

<a href="{{ route('posts.indexRequest') }}">Request List</a>

route

Route::prefix('dashboard')->middleware('role:superadministrator|administrator|editor|author|contributor')->group( function () {
  Route::get('/', 'PagesController@dashboard')->name('dashboard');
  Route::resource('/posts', 'PostController');
  Route::get('/posts/request-list', 'PostController@indexRequest')->name('posts.indexRequest');
});

Post Controller

public function indexRequest()
{
  $posts = Post::where('status', 'On Request')->orderBy('created_at')->paginate(12);

  return view('manages.posts.request', compact('posts'));
}

and I have the view

Folder Structure

  • 写回答

2条回答 默认 最新

  • doujuncuo9339 2018-10-21 15:23
    关注

    You cannot set a get route after a resource route if they use the same prefix.

    The resource route will define posts/{post} as the PostController@show route, equivalent to:

    Route::get('posts/{post}', 'PostController@show')
    

    This will conflict with your bottom route and posts/request-list and will evaluate request-list as a post ID ({post}) in the above route.

    Set all specific routes before resource routes.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?