我需要通过单击按钮将一个附加参数 ($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/