Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

brendt/aggregate.stitcher.io

608 stars
1 code files
View brendt/aggregate.stitcher.io on GitHub

app/App/Admin/ViewModels/AdminAnalyticsViewModel.php

Open in GitHub
use Domain\Source\Models\Source;
use Illuminate\Support\Collection;
use Spatie\ViewModels\ViewModel;
 
final class AdminAnalyticsViewModel extends ViewModel
{
//
public function topSources(): Collection
{
$sources = Source::query()
->selectRaw('sources.*, SUM(posts.view_count) AS view_count, SUM(posts.vote_count) AS vote_count')
->joinPosts()
->groupBy('sources.url')
->applySort($this->request)
->limit(10)
->get();
 
return $sources;
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.