Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| FiltersExecutionDateRange | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| applyExecutionWindowFilter | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Shared\Concerns; |
| 4 | |
| 5 | use Illuminate\Support\Carbon; |
| 6 | |
| 7 | trait FiltersExecutionDateRange |
| 8 | { |
| 9 | protected function applyExecutionWindowFilter($query, string $table, Carbon $startOfDay, Carbon $endOfDay): void |
| 10 | { |
| 11 | $query->where(function ($dateQuery) use ($table, $startOfDay, $endOfDay) { |
| 12 | $dateQuery->where(function ($overlapQuery) use ($table, $startOfDay, $endOfDay) { |
| 13 | $overlapQuery->whereNotNull("$table.start_date") |
| 14 | ->where("$table.start_date", '<=', $endOfDay) |
| 15 | ->where(function ($endDateQuery) use ($table, $startOfDay) { |
| 16 | $endDateQuery->whereNull("$table.end_date") |
| 17 | ->orWhere("$table.end_date", '>=', $startOfDay); |
| 18 | }); |
| 19 | })->orWhere(function ($pendingQuery) use ($table, $endOfDay) { |
| 20 | $pendingQuery->whereNull("$table.start_date") |
| 21 | ->where("$table.created_at", '<=', $endOfDay); |
| 22 | }); |
| 23 | }); |
| 24 | } |
| 25 | } |