Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anonymouse703's avatar

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

0 likes
0 replies

Please or to participate in this conversation.