including working export button
This commit is contained in:
hackerESQ
2024-08-27 22:06:10 -05:00
parent e21814714d
commit 12f3003a3a
16 changed files with 39 additions and 164 deletions
+1 -6
View File
@@ -32,19 +32,14 @@ class DailyChange extends Model
protected $casts = [
'date' => 'datetime',
];
public function scopeMyDailyChanges($query)
{
return $query->where('user_id', auth()->user()->id);
}
public function scopePortfolio($query, $portfolio)
{
return $query->where('portfolio_id', $portfolio);
}
public function portfolio()
{
return $this->belongsTo(Portfolio::class);
}
}
-7
View File
@@ -35,8 +35,6 @@ class Portfolio extends Model
protected $with = ['users', 'transactions'];
protected $appends = ['owner_id'];
public function users()
{
return $this->belongsToMany(User::class)->withPivot('owner');
@@ -69,11 +67,6 @@ class Portfolio extends Model
return $this->hasMany(DailyChange::class);
}
public function scopeMyPortfolios()
{
return $this->whereRelation('users', 'id', auth()->user()->id);
}
public function scopeWithoutWishlists()
{
return $this->where(['wishlist' => false]);
-7
View File
@@ -97,13 +97,6 @@ class Transaction extends Model
return $query->where('symbol', $symbol);
}
public function scopeMyTransactions()
{
return $this->whereHas('portfolio', function ($query) {
return $query->whereRelation('users', 'id', auth()->user()->id);
});
}
public function refreshMarketData()
{
return MarketData::getMarketData($this->attributes['symbol']);
+5
View File
@@ -54,6 +54,11 @@ class User extends Authenticatable
return $this->belongsToMany(Portfolio::class)->withPivot('owner');
}
public function daily_changes()
{
return $this->hasManyDeep(DailyChange::class, ['portfolio_user', Portfolio::class]);
}
public function holdings(): HasManyDeep
{
return $this->hasManyDeep(Holding::class, ['portfolio_user', Portfolio::class])