$removedEmployees = $mergedEmployees->diff($uniqueEmployees);
这是我的代码。
$employees1 = Employee::where('employment_status', '<>', 'SEPARATED')
->where('client_code_1', $client->client_code)
->where('position', $grouping->position)
->where('billable_rate', $grouping->billable_rate)
->get();
$employees2 = Employee::where('employment_status', '<>', 'SEPARATED')
->where('client_code_2', $client->client_code)
->where('position', $grouping->position)
->where('billable_rate', $grouping->billable_rate)
->get();
$mergedEmployees = $employees1->merge($employees2);
$uniqueEmployees = $mergedEmployees->unique();
$removedEmployees = $mergedEmployees->diff($uniqueEmployees);
字符串
1条答案
按热度按时间bxgwgixi1#
Laravel合并状态
第一个月
这里看到
所以这行
$mergedEmployees = $employees1->merge($employees2);
已经创建了一个唯一的数组因此,
$mergedEmployees->diff($uniqueEmployees)
结果为空你应该做的是...
字符串
这里有一个缺点,它不会处理多个副本,如果$mergedEmployees像array(1,1,1,2),$uniqueEmployees像array(1,2),结果将是array(1)