Skip to main content

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

Read more here

alkrauss48/simple-slides

98 stars
2 code files
View alkrauss48/simple-slides on GitHub

app/Models/DailyView.php

Open in GitHub
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
 
class DailyView extends Model
{
// ...
 
public function scopeForUser(Builder $query): void
{
if (auth()->user()->isAdministrator()) {
return;
}
 
$presentationIds = auth()->user()->presentations()->pluck('id');
 
$query->whereIn('presentation_id', $presentationIds);
}
 
// ...
}

app/Filament/Widgets/ViewStats.php

Open in GitHub
use App\Models\DailyView;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
 
class ViewStats extends BaseWidget
{
// ...
 
private function dailyViews(): Stat
{
$views = DailyView::forUser()
->stats(presentationId: $this->filters['presentation_id'])
->get();
 
// ...
}
 
private function aggregateViews(bool $withinRange = false): Stat
{
$views = AggregateView::forUser()
->stats(
presentationId: $this->filters['presentation_id'],
startDate: $withinRange ? $this->filters['start_date'] : null,
endDate: $withinRange ? $this->filters['end_date'] : null,
)->get();
 
// ...
}
}

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.