wip
improve import / export flow and clean up relationships
This commit is contained in:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user