提交表单时传递带有路由参数的变量 Laravel 5.2

Ozm*_*Tis 7 php routing url-routing laravel-5

我在 viewpage.php 的表单中有这个:

<form action="{{ route('test.route'), ['id' => $params_id] }}" method="POST" >
Run Code Online (Sandbox Code Playgroud)

这在 route.php 中:

Route::post('/testing/{{id}}',[
    'uses' => 'TestController@testMethod', 
    'as' => 'test.route'
]);
Run Code Online (Sandbox Code Playgroud)

这是我的 TestController:

public function avaliarSubordinor(Request $request, $uid){
    return $uid;
}
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息,显示“缺少 [Route: test.route] [URI: testing/{{id}}]”的必需参数。本质上,我想要的是在提交表单时使用带有参数的路由将变量传递给我的控制器。

我不知道我是否正确地做这件事..如果有人可以帮助我或给我指出一个例子,这样我就可以理解我做错了什么..

Ozm*_*Tis 6

Laravel 5.2 缺少 [Route: user.profile] [URI: user/{nickname}/profile] 的必需参数

使用上面的链接我找到了一个解决方案..我改变了:

<form action="{{ route('test.route'), ['id' => $params_id] }}" method="POST" >
Run Code Online (Sandbox Code Playgroud)

<form action="{{ route('test.route', [$params_id]) }}" method="GET" >
Run Code Online (Sandbox Code Playgroud)

和这个:

Route::post('/testing/{{id}}',[
     'uses' => 'TestController@testMethod', 
     'as' => 'test.route'
]);
Run Code Online (Sandbox Code Playgroud)

Route::get('/testing/{id}',[
     'uses' => 'TestController@testMethod', 
     'as' => 'test.route'
]);
Run Code Online (Sandbox Code Playgroud)

和阅读价值:

if ($request->id) {
}
Run Code Online (Sandbox Code Playgroud)

它有效!但我想知道是否还有其他人可以获得 POST 版本,还是 GET 是唯一的方法?我不太了解 GET/POST 请求,只知道它在表单和 ajax 中使用.. 真的很想了解更多关于 HTTP GET/POST 的信息,如果有人要添加任何内容,请分享!谢谢!希望这个答案对某人有所帮助!