-
app/Enums/PresentationFilter.php
Open in GitHubenum PresentationFilter: string { use Traits\EnumToArray; case INSTRUCTIONS = 'instructions'; case ADHOC = 'adhoc'; public function label(): string { return match ($this) { self::INSTRUCTIONS => 'Instructions', self::ADHOC => 'Adhoc', }; } }
-
app/Models/DailyView.php
Open in GitHubuse App\Enums\PresentationFilter; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; class DailyView extends Model { // ... public function scopeStats(Builder $query, ?string $presentationId = null): void { if ($presentationId === PresentationFilter::INSTRUCTIONS->value) { $query ->whereNull('presentation_id') ->whereNull('adhoc_slug'); return; } if ($presentationId === PresentationFilter::ADHOC->value) { $query ->whereNull('presentation_id') ->whereNotNull('adhoc_slug') ->get(); return; } if (is_null($presentationId)) { return; } $query->where('presentation_id', intval($presentationId)); } // ... }