mirror of
https://github.com/henry4682/finance_app.git
synced 2026-07-16 08:20:00 +00:00
31 lines
836 B
PHP
31 lines
836 B
PHP
<?php
|
|
|
|
use App\Console\Commands\RefreshAllAssetPrices;
|
|
use Illuminate\Foundation\Inspiring;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Illuminate\Support\Facades\Schedule;
|
|
use App\Jobs\FetchAndParseGmailInvoices;
|
|
use App\Models\User;
|
|
|
|
Artisan::command('inspire', function () {
|
|
$this->comment(Inspiring::quote());
|
|
})->purpose('Display an inspiring quote');
|
|
|
|
Schedule::command(RefreshAllAssetPrices::class)
|
|
->weekdays()
|
|
->at('14:00')
|
|
->at('22:00');
|
|
|
|
Schedule::call(function () {
|
|
// 找出所有有綁定 Google Refresh Token 的使用者
|
|
$users = User::whereNotNull('google_refresh_token')->get();
|
|
|
|
foreach ($users as $user) {
|
|
// 分別派發非同步任務去排隊抓信,不塞車
|
|
FetchAndParseGmailInvoices::dispatch($user);
|
|
}
|
|
})
|
|
->weekdays()
|
|
->at('14:00')
|
|
->at('22:00');
|