Created
September 16, 2021 10:06
-
-
Save cygeorgel/38b37d7520426a9b98647e7923210646 to your computer and use it in GitHub Desktop.
Check conflicts for time span groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function checkConflicts(array $daysOfWeek, array $timeSpan, $callQueueGroupId, $callQueueGroupTimeSpanId = null) | |
{ | |
$conflicts = 0; | |
if ($callQueueGroupTimeSpanId) { | |
foreach ($daysOfWeek as $dayOfWeek) { | |
$conflicts += CallQueueGroupTimeSpan::where('call_queue_group_id', $callQueueGroupId) | |
->where('id', '!=', $callQueueGroupeTimeSpanId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '<=', $timeSpan['start']) | |
->where('end', '>=', $timeSpan['end']) | |
->count(); | |
$conflicts += CallQueueGroupTimeSpan::where('call_queue_group_id', $callQueueGroupId) | |
->where('id', '!=', $callQueueGroupeTimeSpanId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '>=', $timeSpan['start']) | |
->where('end', '<=', $timeSpan['end']) | |
->count(); | |
$conflicts += CallQueueGroupTimeSpan::where('call_queue_group_id', $callQueueGroupId) | |
->where('id', '!=', $callQueueGroupeTimeSpanId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '<=', $timeSpan['start']) | |
->where('end', '>=', $timeSpan['start']) | |
->count(); | |
$conflicts += CallQueueGroupTimeSpan::where('call_queue_group_id', $callQueueGroupId) | |
->where('id', '!=', $callQueueGroupeTimeSpanId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('end', '>=', $timeSpan['end']) | |
->where('start', '<=', $timeSpan['end']) | |
->count(); | |
} | |
} else { | |
foreach ($daysOfWeek as $dayOfWeek) { | |
$conflicts += CallQueueGroupTimeSpan::where('call_queue_group_id', $callQueueGroupId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '<=', $timeSpan['start']) | |
->where('end', '>=', $timeSpan['end']) | |
->count(); | |
$conflicts += CallQueueGroupTimeSpan::where('call_queue_group_id', $callQueueGroupId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '>=', $timeSpan['start']) | |
->where('end', '<=', $timeSpan['end']) | |
->count(); | |
$conflicts += CallQueueGroupTimeSpan::where('call_queue_group_id', $callQueueGroupId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '<=', $timeSpan['start']) | |
->where('end', '>=', $timeSpan['start']) | |
->count(); | |
$conflicts += CallQueueGroupTimeSpan::where('call_queue_group_id', $callQueueGroupId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('end', '>=', $timeSpan['end']) | |
->where('start', '<=', $timeSpan['end']) | |
->count(); | |
} | |
} | |
return $conflicts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment