diff --git a/app/Http/Controllers/Api/Web/StatsController.php b/app/Http/Controllers/Api/Web/StatsController.php index 74815e2c..27f0e7a3 100644 --- a/app/Http/Controllers/Api/Web/StatsController.php +++ b/app/Http/Controllers/Api/Web/StatsController.php @@ -146,6 +146,11 @@ class StatsController extends ApiControllerBase $now = Carbon::now(); $trackDate = $track->published_at; + // Error catching for tracks that don't exist anymore + // or are not published + if ($trackDate == null) + return $this->notFound('Track not found!'); + if ($trackDate->diffInDays($now) >= 1) return $this->getTrackStatsDaily($id);