Created
September 16, 2021 10:08
-
-
Save cygeorgel/7c65052719efe057cd46acbb857f2895 to your computer and use it in GitHub Desktop.
Check cconflicts for time spans
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, $callQueueId, $callQueueTimeSpanId = null) | |
{ | |
$conflicts = 0; | |
if ($callQueueTimeSpanId) { | |
foreach ($daysOfWeek as $dayOfWeek) { | |
$conflicts += CallQueueTimeSpan::where('call_group_id', $callQueueId) | |
->where('id', '!=', $callQueueTimeSpanId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '<=', $timeSpan['start']) | |
->where('end', '>=', $timeSpan['end']) | |
->count(); | |
$conflicts += CallQueueTimeSpan::where('call_group_id', $callQueueId) | |
->where('id', '!=', $callQueueTimeSpanId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '>=', $timeSpan['start']) | |
->where('end', '<=', $timeSpan['end']) | |
->count(); | |
$conflicts += CallQueueTimeSpan::where('call_group_id', $callQueueId) | |
->where('id', '!=', $callQueueTimeSpanId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '<=', $timeSpan['start']) | |
->where('end', '>=', $timeSpan['start']) | |
->count(); | |
$conflicts += CallQueueTimeSpan::where('call_group_id', $callQueueId) | |
->where('id', '!=', $callQueueTimeSpanId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('end', '>=', $timeSpan['end']) | |
->where('start', '<=', $timeSpan['end']) | |
->count(); | |
} | |
} else { | |
foreach ($daysOfWeek as $dayOfWeek) { | |
$conflicts += CallQueueTimeSpan::where('call_group_id', $callQueueId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '<=', $timeSpan['start']) | |
->where('end', '>=', $timeSpan['end']) | |
->count(); | |
$conflicts += CallQueueTimeSpan::where('call_group_id', $callQueueId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '>=', $timeSpan['start']) | |
->where('end', '<=', $timeSpan['end']) | |
->count(); | |
$conflicts += CallQueueTimeSpan::where('call_group_id', $callQueueId) | |
->where('dayOfWeek', $dayOfWeek) | |
->where('start', '<=', $timeSpan['start']) | |
->where('end', '>=', $timeSpan['start']) | |
->count(); | |
$conflicts += CallQueueTimeSpan::where('call_group_id', $callQueueId) | |
->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