Search code examples
phplaravellumen

How to fix Call to a member function where() on int


I have to update some records but it doesn't work properly. Someone know what to do?

$dog = DB::table('dogs')
    ->update($data)
    ->where('id', $id);

return response()->json($dog); })


Solution

  • Call where before update, e.g. :

    $dog = DB::table('dogs')->where('id', $id)->update($data);