doudi8298 2014-01-28 15:03
浏览 182

如何在laravel中创建资源路由

I create a controller named HomeController and their methods named

getIndex() 

and

index()

and after that i make a routing is follows

Route::resource('home', 'HomeController');

But it will gives me this error

Controller method not found.

I have fine working in this routes

Route::controller('/', 'IndexController');

Please help

Update
Thanks all for your help.. I am a beginner to laravel. So I made a big mistake in my routing that I forget about first in first out rule. So I have to reorder my routes from

Route::controller('/', 'IndexController'); 
Route::resource('homes', 'HomesController');

to

Route::resource('homes', 'HomesController');
Route::controller('/', 'IndexController'); 
  • 写回答

4条回答 默认 最新

  • douxu0550 2014-01-28 15:37
    关注

    If you are using a resource controller, you will only need the "index" method. Given your route, you would have to enter: yourdomain.com/home in order to get to the index of Home Controller. If you would like to use the same index method as the home page you would need to add this to your routes file:

    Route::get('/', 'HomeController@index');
    

    Also, make (if you haven't already) run:

    composer dump-autoload
    
    评论

报告相同问题?

悬赏问题

  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢