-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathProcessEligiblePayouts.php
More file actions
35 lines (25 loc) · 920 Bytes
/
ProcessEligiblePayouts.php
File metadata and controls
35 lines (25 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace App\Console\Commands;
use App\Jobs\ProcessPayoutTransfer;
use App\Models\PluginPayout;
use Illuminate\Console\Command;
class ProcessEligiblePayouts extends Command
{
protected $signature = 'payouts:process-eligible';
protected $description = 'Dispatch transfer jobs for pending payouts that have passed the 15-day holding period';
public function handle(): int
{
$eligiblePayouts = PluginPayout::pending()
->where('eligible_for_payout_at', '<=', now())
->get();
if ($eligiblePayouts->isEmpty()) {
$this->info('No eligible payouts to process.');
return self::SUCCESS;
}
foreach ($eligiblePayouts as $payout) {
ProcessPayoutTransfer::dispatch($payout);
}
$this->info("Dispatched {$eligiblePayouts->count()} payout transfer job(s).");
return self::SUCCESS;
}
}