Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
16 | public function unsetTrialEndsAtAction(): void |
||
17 | { |
||
18 | $subscriptions = Subscription::find([ |
||
19 | 'conditions' => 'is_deleted = 0 and is_active = 1' |
||
20 | ]); |
||
21 | |||
22 | foreach ($subscriptions as $subscription) { |
||
23 | $trialEnds = new Datetime($subscription->trial_ends_at); |
||
24 | $trialEnds->setTime(0, 0); |
||
25 | $formattedTrialEnds = $trialEnds->format('Y-m-d'); |
||
26 | |||
27 | if ($formattedTrialEnds == Carbon::today()->toDateString()) { |
||
28 | $subscription->trial_ends_at = null; |
||
29 | |||
30 | if ($subscription->update()) { |
||
31 | echo("Company: {$subscription->id} trial has ended, so its trial_ends_at is NULL \n"); |
||
32 | } |
||
37 |