i want to select the max id from "Users" table and update a column of that row named "status" which is initially set to "0" and after update it will be "1". how can i do that?i tried something like this
$id = DB::table('users')->InsertGetId(
['status' => 0]
);
if($status && $id)
{
DB::table('users')
->select max("id")
->update(['status' => 1]);
}
You can do this:
DB::table('users')
->orderBy('id', 'desc')
->take(1)
->update(['status' => 1]);