我已經(jīng)設(shè)置了在表單中插入數(shù)據(jù)的 POST 方法。我也在 web.php 中設(shè)置了 POST 方法。但每當(dāng)我想通過表單插入數(shù)據(jù)時,它都會顯示不支持 Get 方法。但我在表單和路由中都寫了POST方法。這是我的代碼:形式:<form action="{{url('/admin/prescription/store')}}" method="POST"> @csrfRoute::post('/admin/prescription/store','prescriptionController@store')->name('prescription.store');控制器:public function store(Request $request){ $prescription = new Prescription(); $prescription->full_name = $request->full_name; $prescription->nid = $request->nid; $prescription->address = $request->address; $prescription->contactNum = $request->contactNum; $prescription->health_cond = $request->health_cond; $prescription->desc = $request->desc; $prescription->save(); return redirect() ->route('prescription.store') ->with('success','Prescription added Successfully.'); }
3 回答

慕容3067478
TA貢獻1773條經(jīng)驗 獲得超3個贊
要對兩種類型的請求使用同一條路由,您可以執(zhí)行以下操作:
Route::match(['GET', 'POST'],'/admin/prescription/store', 'ExampleController@store');
- 3 回答
- 0 關(guān)注
- 194 瀏覽
添加回答
舉報
0/150
提交
取消