如何return更新行的一个字段?

How to return one fields of updated rows?

我有以下查询:

$updated = ResultTest::whereIn("client_id", $request->id)->update(array("mode" => 1));

现在 returns $update 标记 (1|0) 如果行已更新。

如何获取字段数组 client_id 而不是布尔值?

使用tap函数:

$results = ResultTest::whereIn("client_id", $request->id);
$updated = tap($results)->update(array("mode" => 1));

return $results->pluck('client_id');

https://medium.com/@taylorotwell/tap-tap-tap-1fc6fc1f93a6