Add market data scope

This commit is contained in:
hackerESQ
2024-08-28 15:19:20 -05:00
parent 8a136fe1d7
commit e684c1f4a3
4 changed files with 27 additions and 27 deletions
+11
View File
@@ -86,6 +86,17 @@ class Transaction extends Model
{
return $this->belongsTo(Portfolio::class);
}
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')
->withAggregate('market_data', 'updated_at')
->join('market_data', 'transactions.symbol', 'market_data.symbol');
}
public function scopePortfolio($query, $portfolio)
{