improve naming for query scopes
This commit is contained in:
@@ -114,7 +114,7 @@
|
||||
|
||||
@livewire('transactions-list', [
|
||||
'portfolio' => $holding->portfolio,
|
||||
'transactions' => $transactions,
|
||||
'transactions' => $holding->transactions,
|
||||
'shouldGoToHolding' => false
|
||||
])
|
||||
|
||||
|
||||
@@ -39,14 +39,16 @@ new class extends Component {
|
||||
|
||||
public function holdings(): Collection
|
||||
{
|
||||
return $this->portfolio
|
||||
->holdings()
|
||||
->withCount(['transactions as num_transactions' => function ($query) {
|
||||
$query->where('portfolio_id', $this->portfolio->id);
|
||||
}])
|
||||
->orderBy(...array_values($this->sortBy))
|
||||
->where('quantity', '>', 0)
|
||||
->get();
|
||||
$holdings = $this->portfolio
|
||||
->holdings()
|
||||
->withCount(['transactions as num_transactions' => function($query) {
|
||||
return $query->whereRaw('transactions.symbol = holdings.symbol');
|
||||
}])
|
||||
->orderBy(...array_values($this->sortBy))
|
||||
->where('holdings.quantity', '>', 0)
|
||||
->get();
|
||||
|
||||
return $holdings;
|
||||
}
|
||||
|
||||
public function goToHolding($holding)
|
||||
|
||||
@@ -52,7 +52,7 @@ new class extends Component {
|
||||
// $key = 'portfolio-metrics-' . $portfolio->id;
|
||||
// $metrics = cache()->remember($key, 60, function () use ($portfolio) {
|
||||
// return Holding::where(['portfolio_id' => $portfolio->id])
|
||||
// ->getPortfolioMetrics()
|
||||
// ->withPortfolioMetrics()
|
||||
// ->first();
|
||||
// });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user