Laravel 8 diffAssoc() {#collection-method}
diffAssoc
方法与另外一个集合或基于 PHP 数组的键 / 值对进行比较。这个方法将会返回原集合不存在于指定集合的键 / 值对:
$collection = collect([
'color' => 'orange',
'type' => 'fruit',
'remain' => 6,
]);
$diff = $collection->diffAssoc([
'color' => 'yellow',
'type' => 'fruit',
'remain' => 3,
'used' => 6,
]);
$diff->all();
// ['color' => 'orange', 'remain' => 6]