gpt4 book ai didi

php - Laravel 将附加参数传递给 Controller

转载 作者:可可西里 更新时间:2023-11-01 01:15:37 28 4
gpt4 key购买 nike

我需要通过单击按钮将一个附加参数 ($uid) 从我的 index.blade.php 传递到我的 edit.blade.php。

我的 index.blade.php:

<a href="{!!action('FlyersController@edit', ['id' => Auth::user()->id, 'uid' => 1])!!}" type="button" class="btn btn-block btn-lg btn-info vorlageBtn card-link">Edit </a>

我的传单 Controller :

public function edit($id, $uid)
{

return view('backend.flyers.edit')->withUid($uid);
}

使用上面的代码我得到一个错误:“Missing argument 2 for App\Http\Controllers\FlyersController::edit()”

我在这里做错了什么?

最佳答案

错误不是从操作方法中抛出的。它来自该 URL 的路由。

检查用于将参数传递给 Controller ​​的 URL。

如果这是您想要的 URL localhost:8000/backend/flyers/10/edit?%24uid=1 那么第二个参数在 $request 变量中而不是在 Controller 函数参数中。

关于php - Laravel 将附加参数传递给 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39724522/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com