samedi 28 septembre 2019

Single column not being updated in laravel 5

I am tying to update a single column of a table messages and I have the following code:

  public function messageSeen(Request $request){
        $data = Message::find($request->id);
        $success = Message::where('id', $request->id)->update(array('is_seen' => 1));
        if($success){
            return response()->json(['status'=>'success'], 200);
        } else {
            return response()->json(['status'=>'Data not updated'], 404);
        }
    }

I am getting the response Data not updated. If you question, does the column is_seen exists? then yes it does. Even I tried fetching the data having id $request->id, it gives the proper data. I wonder why is the data not being updated? Am I doing right thing to update column or is there an way out to update column in different way?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire