0

i want to update a first record status into '2' based on button click. Here is my code :

     public function repay(Request $request,$loanid){

    $obj = DB::table('schdls')
    ->where('schdls.loanid','=',$loanid)
    ->where('schdls.status','=',1)->first();
   
   
        $obj->status='2';
        $obj->save();
   
    return redirect('/home')->with('message','updated');
      }

But it says Call to undefined method stdClass::save() error,

What am i missing?

2 Answers 2

0

Check if $obj is null before assigning value on it.

Use dd/dump/var_dump function to check the value and the type of $obj after getting record from database.

0

Try using update(['status' => '2']); instead of save()

DB::table('schdls')
    ->where('status','=',1)->update(['status' => 2]);

Not the answer you're looking for? Browse other questions tagged or ask your own question.