Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Wallet/TrialEndCommand.php
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | public function handle() | ||||
$query->from('entitlements') | $query->from('entitlements') | ||||
->where('entitlements.entitleable_type', \App\User::class) | ->where('entitlements.entitleable_type', \App\User::class) | ||||
->whereColumn('entitlements.entitleable_id', 'wallets.user_id') | ->whereColumn('entitlements.entitleable_id', 'wallets.user_id') | ||||
->whereColumn('entitlements.wallet_id', 'wallets.id'); | ->whereColumn('entitlements.wallet_id', 'wallets.id'); | ||||
}) | }) | ||||
->cursor(); | ->cursor(); | ||||
foreach ($wallets as $wallet) { | foreach ($wallets as $wallet) { | ||||
// Skip accounts with no trial period, or a period longer than a month | |||||
$plan = $wallet->plan(); | |||||
if (!$plan || $plan->free_months != 1) { | |||||
continue; | |||||
} | |||||
// Send the email asynchronously | // Send the email asynchronously | ||||
\App\Jobs\TrialEndEmail::dispatch($wallet->owner); | \App\Jobs\TrialEndEmail::dispatch($wallet->owner); | ||||
// Store the timestamp | // Store the timestamp | ||||
$wallet->setSetting('trial_end_notice', (string) \now()); | $wallet->setSetting('trial_end_notice', (string) \now()); | ||||
} | } | ||||
} | } | ||||
} | } |