wip
including working export button
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user