Skip to content

Commit 3c96fd5

Browse files
committed
change query condition and variables' names
1 parent c7780da commit 3c96fd5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

app/Http/Controllers/PoliciesController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ public function getCurrentPolicies(): PoliciesCollection {
2626
public function getMissingPolicies(Request $request): PoliciesCollection {
2727
$now = CarbonImmutable::now();
2828

29-
// This works based on the assumption that the latest policy has the highest id given that id is AUTO_INCREMENT
30-
$latestPolicyIds = Policy::where('active_from', '<', $now)
29+
// This works based on the assumption that the active policy has the highest id given that id is AUTO_INCREMENT
30+
$activePolicyIds = Policy::where('active_from', '<=', $now)
3131
->selectRaw('MAX(id) as id')
3232
->groupBy('policy_type')
3333
->pluck('id');
3434

3535
$acceptedPolicyIds = PolicyAcceptance::where('user_id', $request->user()->id)
36-
->whereIn('policy_id', $latestPolicyIds)
36+
->whereIn('policy_id', $activePolicyIds)
3737
->pluck('policy_id');
3838

39-
$missingPolicies = Policy::whereIn('id', $latestPolicyIds)
39+
$missingPolicies = Policy::whereIn('id', $activePolicyIds)
4040
->whereNotIn('id', $acceptedPolicyIds)
4141
->get();
4242

0 commit comments

Comments
 (0)