更新时间:2023-12-01 09:04:34
您可以使用 keyBy()
收集方法.
You could use the keyBy()
method of collection.
$unfiltered = DB::table('contracts AS C')->paginate(1);
$filtered = $unfiltered->keyBy(function ($value, $key) {
if ($key == 'data') {
return 'parties';
} else {
return $key;
}
});
return $filtered;