简体   繁体   English

Laravel 资源路由到 root

[英]Laravel resource route to root

Is it possible to set a resource route to root?是否可以将资源路由设置为 root?

Like:喜欢:

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

So I could use these urls:所以我可以使用这些网址:

/
/create
/214
/214/edit

I've tried, create , index works, route('store') recognized, but doesn't call store the function and redirects to home.我试过, createindex有效, route('store') 识别,但不调用 store 函数并重定向到 home。

Not sure if you still need help with this one, since it's been more than a year.不确定您是否还需要帮助来解决这个问题,因为已经一年多了。 Try putting this in your blade file.试着把它放在你的刀片文件中。

<form action="{{ route('store') }}" method="POST">

I've had a similar problem with my code.我的代码也有类似的问题。 My original form had this, at the very beginning (using default documentation code here):我的原始表单一开始就有这个(此处使用默认文档代码):

<form action="{{ route('photo.store') }}>

which, after trying it out, didn't work as I would expect - nothing was being stored.在尝试之后,它并没有像我预期的那样工作 - 没有存储任何内容。 After making sure that the rest of the code was OK, one of my colleagues suggested that I type in the method type, since the default method is GET , and you need the POST method for storing .在确定剩下的代码没问题后,我的一位同事建议我输入方法类型,因为默认方法是 GET ,而您需要 POST 方法来存储

All you need to do is Route::resource('/', 'HomeController');你需要做的就是Route::resource('/', 'HomeController'); . .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM