当使用它为“ controller@method”时,找不到返回控制器。在拉拉维尔

发布于 2025-02-13 12:47:10 字数 395 浏览 0 评论 0原文

我正在尝试使步骤的资源路由与这样的链接中传递的ID一起使用,例如“/step/{howitwork:id}/create”,创建方法如下:

public function create(HowItWork $how){
  ...
}

因此,在我在控制器中定义资源路由之前:

Route::get('steps/{howitwork:id}/create/', [
   'as' => 'steps.create',
   'uses' => 'StepController@create'
]);

返回的应用程序是:

目标类[Stepcontroller]不存在。

I'm trying to make the resource route of steps work with id passed in the link like this "/steps/{howitwork:id}/create" and the create method looks like this:

public function create(HowItWork $how){
  ...
}

so before I define the resource route in the controller:

Route::get('steps/{howitwork:id}/create/', [
   'as' => 'steps.create',
   'uses' => 'StepController@create'
]);

what the app returning is:

Target class [StepController] does not exist.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

枫林﹌晚霞¤ 2025-02-20 12:47:10

您已经在资源路线下添加代码,然后尝试。

**Route::resrouce('something', SomethingController::class);
**Route::get('steps/{howitwork}/create', [StepController::class, 'create'])->as('steps.create');

you have add code under the resource route and try with this.

**Route::resrouce('something', SomethingController::class);
**Route::get('steps/{howitwork}/create', [StepController::class, 'create'])->as('steps.create');
倾城°AllureLove 2025-02-20 12:47:10

我建议您使用此语法:

Route::get('/', [YourController::class, 'your-method'])->name('your-route-name')->middleware(['your-middleware-1', 'your-middleware-2', 'your-middleware-3']);

I suggest you to use this syntax:

Route::get('/', [YourController::class, 'your-method'])->name('your-route-name')->middleware(['your-middleware-1', 'your-middleware-2', 'your-middleware-3']);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文