diff --git a/app/Models/DailyChange.php b/app/Models/DailyChange.php index a97d16e..b0065ae 100644 --- a/app/Models/DailyChange.php +++ b/app/Models/DailyChange.php @@ -42,7 +42,7 @@ class DailyChange extends Model { return $this->whereHas('portfolio', function ($query) { $query->whereHas('users', function ($query) { - $query->where('id', auth()->id()); + return $query->where('id', auth()->id()); }); }); } diff --git a/resources/views/livewire/portfolio-performance-chart.blade.php b/resources/views/livewire/portfolio-performance-chart.blade.php index 9c3a23f..492a783 100644 --- a/resources/views/livewire/portfolio-performance-chart.blade.php +++ b/resources/views/livewire/portfolio-performance-chart.blade.php @@ -45,10 +45,14 @@ new class extends Component { date, SUM(total_market_value) as total_market_value, SUM(total_cost_basis) as total_cost_basis, - SUM(total_gain) as total_gain, - --SUM(realized_gains) as realized_gains, - --SUM(total_dividends_earned) as total_dividends_earned - ')->groupBy('date'); + SUM(total_gain) as total_gain + /* , + SUM(realized_gains) as realized_gains, + SUM(total_dividends_earned) as total_dividends_earned + */ + ') + ->groupBy('date') + ->orderByDesc('date'); } diff --git a/routes/web.php b/routes/web.php index 3637157..d0b2793 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,6 +5,7 @@ use App\Http\Controllers\HoldingController; use App\Http\Controllers\DashboardController; use App\Http\Controllers\PortfolioController; use App\Http\Controllers\TransactionController; +use App\Models\DailyChange; use Laravel\Jetstream\Http\Controllers\Livewire\PrivacyPolicyController; use Laravel\Jetstream\Http\Controllers\Livewire\TermsOfServiceController; @@ -19,6 +20,14 @@ Route::get('/', function () { Route::get('/test', function () { // + return DailyChange::myDailyChanges()->selectRaw(' + date, + SUM(total_market_value) as total_market_value, + SUM(total_cost_basis) as total_cost_basis, + SUM(total_gain) as total_gain + ') + ->groupBy('date') + ->orderByDesc('date')->get()->toArray(); }); Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified'])->group(function () {