Php Laravel 8:缺少必需的参数
我想向web路由发送一些数据,如下所示:Php Laravel 8:缺少必需的参数,php,laravel,laravel-8,Php,Laravel,Laravel 8,我想向web路由发送一些数据,如下所示: 然后在web.php上,我添加了以下内容: Route::post('questions/{question}{asker}/answer',[QuestionController::class,'postAnswer'])->name('questions.answers') 但现在它说: 缺少[Route:questions.answers]的必需参数。 那么这里出了什么问题?如何将$show->id和$show->user->name传递到问题。
然后在web.php
上,我添加了以下内容:
Route::post('questions/{question}{asker}/answer',[QuestionController::class,'postAnswer'])->name('questions.answers')代码>
但现在它说:
缺少[Route:questions.answers]的必需参数。
那么这里出了什么问题?如何将$show->id
和$show->user->name
传递到问题。答案
路线
我非常感谢你们的任何想法或建议
提前感谢。如果您想将应答作为参数传递,可以使用以下代码:
您的刀片文件
<form method="post" action="{{ route('questions.answers', ['question' => '', 'asker' => '', 'answer' => '']) }}" enctype="multipart/form-data">
@csrf
//---Your Data
</form>
<form method="post" action="{{ route('questions.answers', ['question' => '', 'asker' => '']) }}" enctype="multipart/form-data">
@csrf
//---Your Answer Here
</form>
如果您想在表格中发送答案,请使用以下代码:
您的刀片文件
<form method="post" action="{{ route('questions.answers', ['question' => '', 'asker' => '', 'answer' => '']) }}" enctype="multipart/form-data">
@csrf
//---Your Data
</form>
<form method="post" action="{{ route('questions.answers', ['question' => '', 'asker' => '']) }}" enctype="multipart/form-data">
@csrf
//---Your Answer Here
</form>
它将如何识别-{question}{asker}
?@SougataBose我已经通过了{route('questions.answers',$show->id,$show->user->name)}
表单操作,这是错的吗?谢谢,你介意在这里检查我的另一个问题吗:没问题,我已经添加了答案,看看它是否解决了你的问题。