Sep 22, 2020
0
Level 6
How to update record using api resource controller and vue form?
Hello guys, newbee here.
I want to update a record using vue-form and api resource controller. I have request payload and the status in the network was 200 but it doesn't updated in my database.
this how I called my update.
updateMoneyTrans(){
this.form.put('/api/money-trans/'+this.form.id)
.then(({data})=>{
console.log(data);
$('#add_moneytrans').modal('hide');
this.mounted();
})
.catch(()=>{
})
},
and this is my api link
route::resource('money-trans','MoneyTransferController');
and this is my controller
public function update(Request $request, MoneyTransfer $moneyTransfer)
{
try {
$this->validate($request, [
'name' => 'required'
]);
dd($request->all());
$moneyTransfer->update($request->all());
} catch(Exception $e) {
session()->flush('error', $e->getMessage());
return redirect()->back()->withInput();
}
return $moneyTransfer;
session()->flash('edit', 'Plan content updated');
}
Note: I'm using Laravel 7
Please or to participate in this conversation.