我有一个评论表,我正在尝试使用评论和ticket_id提交,但是由于某种原因,数据未随请求传递。我在输入上使用name=""
属性。我尝试转储请求信息dd($request->all())
,返回的唯一内容是csrf_token
和files=>null
。
表格:
<form method="POST" action="{{ route('admin.returns.postComment') }}">
{{ csrf_field() }}
<input type="hidden" style="display: none;" name="rma_ticket_id" value="{{ $rma->rma_ticket_id }}" disabled>
<div class="js-summernote" name="comment"></div>
<div class="mt-3 clearfix">
<button type="submit" class="btn btn-primary float-right">
<i class="fa fa-plus mr-1"></i> Post Comment
</button>
@if ($rma->status->name != "Closed")
<button type="button" class="btn btn-danger float-left">
<i class="fa fa-times mr-1"></i> Close
</button>
@endif
</div>
</form>
控制器:
/**
* Post comment and notify the customer.
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function postComment(Request $request)
{
try {
dd($request->all());
$comment = RmaComments::create([
'user_id' => Auth::user()->id,
'rma_ticket_id' => $request->input('rma_ticket_id'),
'name' => Auth::user()->first_name.''.Auth::user()->last_name,
'comment' => $request->input('comment'),
]);
// TODO - add function to notify customer when message is posted.
return redirect()->back()->with('success', 'Your comment has be submitted to the customer.');
} catch (\Exception $e)
{
// return redirect()->back()->with('danger', 'There was a problem trying to post your comment.');
return redirect()->back()->with('danger', $e->getMessage());
}
}
路线:
Route::post('/returns/postComment', 'Backend\RmaController@postComment')->name('admin.returns.postComment');