feat:adds user option to sync and refresh commands

This commit is contained in:
hackerESQ
2024-10-23 16:57:55 -05:00
parent ab24b528d1
commit ff725e0119
4 changed files with 25 additions and 11 deletions
+8 -3
View File
@@ -12,7 +12,8 @@ class SyncHoldingData extends Command
*
* @var string
*/
protected $signature = 'sync:holdings';
protected $signature = 'sync:holdings
{--user= : Limit refresh to user\'s holdings}';
/**
* The console command description.
@@ -39,9 +40,13 @@ class SyncHoldingData extends Command
public function handle()
{
// get all holdings
$holdings = Holding::get();
$holdings = Holding::query();
foreach ($holdings as $holding) {
if ($this->option('user')) {
$holdings->myHoldings($this->option('user'));
}
foreach ($holdings->get() as $holding) {
$this->line('Refreshing ' . $holding->symbol);
$holding->syncTransactionsAndDividends();