From 7b4cf4adff975615402201d77395e273b1033512 Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Wed, 4 May 2016 01:26:52 +0100 Subject: [PATCH] Fixed error for unpublished tracks --- app/Http/Controllers/Api/Web/StatsController.php | 5 +++++ 1 file changed, 5 insertions(+) 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);