2024-08-29 23:36:44 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
2024-08-30 21:58:38 -05:00
|
|
|
use App\Models\Split;
|
2024-08-29 23:36:44 -05:00
|
|
|
use App\Models\Holding;
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
2024-08-30 21:58:38 -05:00
|
|
|
class RefreshSplitData extends Command
|
2024-08-29 23:36:44 -05:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The name and signature of the console command.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2024-09-06 22:26:54 -05:00
|
|
|
protected $signature = 'refresh:split-data
|
2024-08-30 21:58:38 -05:00
|
|
|
{--force= : Don\'t ask to confirm.}';
|
2024-08-29 23:36:44 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The console command description.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2024-08-30 21:58:38 -05:00
|
|
|
protected $description = 'Refresh split data from data provider';
|
2024-08-29 23:36:44 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new command instance.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute the console command.
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function handle()
|
|
|
|
|
{
|
2024-09-05 21:21:18 -05:00
|
|
|
$holdings = Holding::where('quantity', '>', 0)->distinct()->get(['symbol']);
|
2024-08-29 23:36:44 -05:00
|
|
|
|
|
|
|
|
foreach ($holdings as $holding) {
|
|
|
|
|
$this->line('Refreshing ' . $holding->symbol);
|
2024-09-01 21:18:09 -05:00
|
|
|
|
2024-08-30 21:58:38 -05:00
|
|
|
Split::refreshSplitData($holding->symbol);
|
|
|
|
|
}
|
2024-08-29 23:36:44 -05:00
|
|
|
}
|
|
|
|
|
}
|