improve import / export flow and clean up relationships
This commit is contained in:
hackerESQ
2024-08-28 22:06:47 -05:00
parent e684c1f4a3
commit 69c43dc41f
15 changed files with 104 additions and 74 deletions
+9 -1
View File
@@ -90,7 +90,6 @@ class Transaction extends Model
public function scopeWithMarketData($query)
{
$query->withAggregate('market_data', 'name')
->withAggregate('portfolio', 'title')
->withAggregate('market_data', 'market_value')
->withAggregate('market_data', 'fifty_two_week_low')
->withAggregate('market_data', 'fifty_two_week_high')
@@ -108,6 +107,15 @@ class Transaction extends Model
return $query->where('symbol', $symbol);
}
public function scopeMyTransactions()
{
return $this->whereHas('portfolio', function ($query) {
$query->whereHas('users', function ($query) {
$query->where('id', auth()->id());
});
});
}
public function refreshMarketData()
{
return MarketData::getMarketData($this->attributes['symbol']);