【发布时间】:2019-09-09 12:15:20
【问题描述】:
我想将数据更新到 ionic 中的数据库。如何进行数据更新。这是我尝试过的。我尝试使用邮递员发布 api,它似乎成功但数据没有改变。
在 api.php 中
public function update (Request $request)
{
$id = $request->id;
$medname = $request->medname;
$price = $request->price;
$stock = $request->stock;
$medno = $request->medno;
$ingredient = $request->ingredient;
$description = $request->description;
$addinfo = $request->addinfo;
AddMedicine:: where('medname',$medname)->update([
'id' =>$id,
'medname'=>$medname,
'price'=>$price,
'stock'=>$stock,
'medno'=>$medno,
'ingredient'=>$ingredient,
'description'=>$description,
'addinfo'=>$addinfo,
]);
$msg = "Data Updated";
$datamsg = response()->json([
'success' => $msg
]);
return $datamsg->content();
}
路线
Route::put('/update','ApiController@update');
【问题讨论】: